13#include <py2cpp/py2cpp.hpp>
20template <
typename T>
using Value_type =
typename T::value_type;
41 template <
typename _nodeview_t,
typename adjlist_t = py::set<Value_type<_nodeview_t>>,
42 typename adjlist_outer_dict_factory = py::dict<Value_type<_nodeview_t>, adjlist_t>>
46 using Node =
typename nodeview_t::value_type;
57 using edge_t = std::pair<Node, Node>;
120 using T = std::remove_reference_t<
decltype(this->
_adj)>;
127 using T = std::remove_cv_t<
decltype(this->
_adj)>;
166 auto begin()
const {
return std::begin(this->_node); }
170 auto end()
const {
return std::end(this->_node); }
195 using T = std::remove_reference_t<
decltype(*this)>;
224 std::vector<edge_t>
result;
226 for (
const auto&
nbr : this->_adj[
node]) {
245 typename std::enable_if<std::is_same<U, value_type>::value>
::type {
256 typename std::enable_if<!std::is_same<U, value_type>::value>
::type {
279 for (
const auto&
e :
edges) {
291 for (
const auto&
e :
edges) {
324 for (
const auto&
nbr : this->_adj[
node]) {
344 std::vector<py::set<uint32_t>>>;
Read-only map of maps of maps (view into a dict-of-dict-of-dict structure)
Definition coreviews.hpp:109
AdjacencyView(Atlas &d)
Construct an AdjacencyView from an Atlas container.
Definition coreviews.hpp:115
auto at(const T &key) const -> const auto &
Access element at specified key (const version)
Definition coreviews.hpp:79
auto begin() const
Get iterator to the beginning of the view.
Definition coreviews.hpp:55
auto size() const -> size_t
Get the number of elements in the view.
Definition coreviews.hpp:49
Undirected graph with arbitrary node types.
Definition graph.hpp:43
auto add_edge(const Node &node_u, const Node &node_v) -> typename std::enable_if<!std::is_same< U, value_type >::value >::type
Add an edge between two nodes (for complex key type, SFINAE)
Definition graph.hpp:255
auto size() const -> size_t
Get the number of nodes (same as number_of_nodes)
Definition graph.hpp:214
auto is_directed() const
Check if the graph is directed.
Definition graph.hpp:338
typename adjlist_t::value_type value_type
Definition graph.hpp:56
auto contains(const Node &node) const -> bool
Check if a node is in the graph.
Definition graph.hpp:175
static auto end_points(const edge_t &e) -> const edge_t &
For compatible with BGL adaptor.
Definition graph.hpp:115
auto operator[](const Node &node) const -> const auto &
Access adjacency dict of a node (const version)
Definition graph.hpp:180
auto edges() const -> std::vector< edge_t >
Return a vector of all edges as (u, v) pairs.
Definition graph.hpp:223
Graph(uint32_t num_nodes)
Construct a graph with a given number of integer nodes.
Definition graph.hpp:92
auto order() const
Get the number of nodes (same as number_of_nodes)
Definition graph.hpp:210
Graph(const nodeview_t &Nodes)
Construct a graph from a node container.
Definition graph.hpp:85
_nodeview_t nodeview_t
Definition graph.hpp:45
static auto end_points(edge_t &e) -> edge_t &
For compatible with BGL adaptor.
Definition graph.hpp:107
auto operator[](const Node &node) -> auto &
Access adjacency dict of a node (non-const version)
Definition graph.hpp:190
auto add_edge(const Node &node_u, const Node &node_v, const T &data)
Add an edge with attached data.
Definition graph.hpp:269
auto has_node(const Node &node) const -> bool
Check if the graph contains a node.
Definition graph.hpp:238
auto end() const
End iterator over nodes.
Definition graph.hpp:170
auto has_edge(const Node &node_u, const Node &node_v) const -> bool
Check if an edge exists between two nodes.
Definition graph.hpp:301
auto add_edges_from(const C1 &edges)
Add edges from a container of edge pairs.
Definition graph.hpp:278
size_t _num_of_edges
Number of edges in the graph (cached)
Definition graph.hpp:60
auto is_multigraph() const
Check if the graph is a multigraph.
Definition graph.hpp:334
auto nodes()
Get a NodeView of the graph.
Definition graph.hpp:194
auto at(const Node &node) const -> const auto &
Access adjacency dict of a node with bounds check (const version)
Definition graph.hpp:185
typename adjlist_t::key_type key_type
Definition graph.hpp:55
auto adj()
Get the adjacency mapping of the graph (non-const version)
Definition graph.hpp:126
nodeview_t _node
Container holding all nodes in the graph.
Definition graph.hpp:63
Node node_t
Definition graph.hpp:58
std::pair< Node, Node > edge_t
Definition graph.hpp:57
auto add_edge(const Node &node_u, const Node &node_v) -> typename std::enable_if< std::is_same< U, value_type >::value >::type
Add an edge between two nodes (for simple key type, SFINAE)
Definition graph.hpp:244
auto for_each_edge(F &&func) const -> void
Apply a callable to each edge without materializing a vector.
Definition graph.hpp:322
auto begin() const
Begin iterator over nodes.
Definition graph.hpp:166
typename nodeview_t::value_type Node
Definition graph.hpp:46
auto degree(const Node &node) const
Get the degree of a node.
Definition graph.hpp:308
auto clear()
Remove all nodes and edges from the graph.
Definition graph.hpp:311
auto _nodes_nbrs() const
Iterate over nodes and their neighbors.
Definition graph.hpp:133
auto number_of_nodes() const -> size_t
Get the number of nodes in the graph.
Definition graph.hpp:206
adjlist_outer_dict_factory _adj
Adjacency dictionary keyed by node.
Definition graph.hpp:66
auto add_edges_from(const C1 &edges, const C2 &data)
Add edges from a container with associated data.
Definition graph.hpp:289
auto adj() const
Get the adjacency mapping of the graph (const version)
Definition graph.hpp:119
auto number_of_edges() const -> size_t
Get the number of edges in the graph.
Definition graph.hpp:218
Read-only view classes for graph data structures.
typename T::value_type Value_type
Alias for the value_type of a container.
Definition graph.hpp:20
Definition hadlock.hpp:32
Definition digraphs.hpp:24
View classes for nodes, edges, and degrees in XNetwork graphs.