|
XNetwork 1.7.5; VERSION ${PROJECT_VERSION}
|
Undirected graph with arbitrary node types. More...
#include <graph.hpp>

Public Types | |
| using | nodeview_t = _nodeview_t |
| using | Node = typename nodeview_t::value_type |
| using | adjlist_inner_dict_factory = adjlist_t |
| using | key_type = typename adjlist_t::key_type |
| using | value_type = typename adjlist_t::value_type |
| using | edge_t = std::pair< Node, Node > |
| using | node_t = Node |
Public Member Functions | |
| Graph (const nodeview_t &Nodes) | |
| Construct a graph from a node container. | |
| Graph (uint32_t num_nodes) | |
| Construct a graph with a given number of integer nodes. | |
| auto | adj () const |
| Get the adjacency mapping of the graph (const version) | |
| auto | adj () |
| Get the adjacency mapping of the graph (non-const version) | |
| auto | _nodes_nbrs () const |
| Iterate over nodes and their neighbors. | |
| auto | begin () const |
| Begin iterator over nodes. | |
| auto | end () const |
| End iterator over nodes. | |
| auto | contains (const Node &node) const -> bool |
| Check if a node is in the graph. | |
| auto | operator[] (const Node &node) const -> const auto & |
| Access adjacency dict of a node (const version) | |
| auto | at (const Node &node) const -> const auto & |
| Access adjacency dict of a node with bounds check (const version) | |
| auto | operator[] (const Node &node) -> auto & |
| Access adjacency dict of a node (non-const version) | |
| auto | nodes () |
| Get a NodeView of the graph. | |
| auto | number_of_nodes () const -> size_t |
| Get the number of nodes in the graph. | |
| auto | order () const |
| Get the number of nodes (same as number_of_nodes) | |
| auto | size () const -> size_t |
| Get the number of nodes (same as number_of_nodes) | |
| auto | number_of_edges () const -> size_t |
| Get the number of edges in the graph. | |
| auto | edges () const -> std::vector< edge_t > |
| Return a vector of all edges as (u, v) pairs. | |
| auto | has_node (const Node &node) const -> bool |
| Check if the graph contains a node. | |
| template<typename U = key_type> | |
| 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) | |
| template<typename U = key_type> | |
| 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) | |
| template<typename T > | |
| auto | add_edge (const Node &node_u, const Node &node_v, const T &data) |
| Add an edge with attached data. | |
| template<typename C1 > | |
| auto | add_edges_from (const C1 &edges) |
| Add edges from a container of edge pairs. | |
| template<typename C1 , typename C2 > | |
| auto | add_edges_from (const C1 &edges, const C2 &data) |
| Add edges from a container with associated data. | |
| auto | has_edge (const Node &node_u, const Node &node_v) const -> bool |
| Check if an edge exists between two nodes. | |
| auto | degree (const Node &node) const |
| Get the degree of a node. | |
| auto | clear () |
| Remove all nodes and edges from the graph. | |
| template<typename F > | |
| auto | for_each_edge (F &&func) const -> void |
| Apply a callable to each edge without materializing a vector. | |
| auto | is_multigraph () const |
| Check if the graph is a multigraph. | |
| auto | is_directed () const |
| Check if the graph is directed. | |
Static Public Member Functions | |
| static auto | end_points (edge_t &e) -> edge_t & |
| For compatible with BGL adaptor. | |
| static auto | end_points (const edge_t &e) -> const edge_t & |
| For compatible with BGL adaptor. | |
Public Attributes | |
| size_t | _num_of_edges = 0 |
| Number of edges in the graph (cached) | |
| nodeview_t | _node |
| Container holding all nodes in the graph. | |
| adjlist_outer_dict_factory | _adj |
| Adjacency dictionary keyed by node. | |
Undirected graph with arbitrary node types.
A Graph stores nodes and edges with optional data or attributes. Graphs hold undirected edges. Self loops are allowed but multiple (parallel) edges are not. Nodes can be arbitrary (hashable) C++ objects.
The Graph class uses a container-of-container-of-container data structure. The outer dict (node_dict) holds adjacency information keyed by node. The next dict (adjlist_dict) represents the adjacency information and holds edge data keyed by neighbor. The inner dict (edge_attr_dict) represents the edge data and holds edge attribute values keyed by attribute names.
| using xnetwork::Graph< _nodeview_t, adjlist_t, adjlist_outer_dict_factory >::adjlist_inner_dict_factory = adjlist_t |
| using xnetwork::Graph< _nodeview_t, adjlist_t, adjlist_outer_dict_factory >::edge_t = std::pair<Node, Node> |
| using xnetwork::Graph< _nodeview_t, adjlist_t, adjlist_outer_dict_factory >::key_type = typename adjlist_t::key_type |
| using xnetwork::Graph< _nodeview_t, adjlist_t, adjlist_outer_dict_factory >::Node = typename nodeview_t::value_type |
| using xnetwork::Graph< _nodeview_t, adjlist_t, adjlist_outer_dict_factory >::node_t = Node |
| using xnetwork::Graph< _nodeview_t, adjlist_t, adjlist_outer_dict_factory >::nodeview_t = _nodeview_t |
| using xnetwork::Graph< _nodeview_t, adjlist_t, adjlist_outer_dict_factory >::value_type = typename adjlist_t::value_type |
|
inlineexplicit |
Construct a graph from a node container.
| [in] | Nodes | Container of nodes to initialize the graph |
|
inlineexplicit |
Construct a graph with a given number of integer nodes.
| [in] | num_nodes | Number of nodes (0 to num_nodes-1) |
|
inline |
Iterate over nodes and their neighbors.
|
inline |
Add an edge between two nodes (for simple key type, SFINAE)
| U | Key type parameter for SFINAE dispatch |
| [in] | node_u | First endpoint of the edge |
| [in] | node_v | Second endpoint of the edge |
|
inline |
Add an edge between two nodes (for complex key type, SFINAE)
| U | Key type parameter for SFINAE dispatch |
| [in] | node_u | First endpoint of the edge |
| [in] | node_v | Second endpoint of the edge |
|
inline |
Add an edge with attached data.
| T | Type of edge data |
| [in] | node_u | First endpoint |
| [in] | node_v | Second endpoint |
| [in] | data | Data to associate with the edge |
|
inline |
Add edges from a container of edge pairs.
| C1 | Container type for edges |
| [in] | edges | Container of edge pairs |
|
inline |
Add edges from a container with associated data.
| C1 | Container type for edges |
| C2 | Container type for edge data |
| [in] | edges | Container of edge pairs |
| [in] | data | Container of edge data values |
|
inline |
Get the adjacency mapping of the graph (non-const version)
|
inline |
Get the adjacency mapping of the graph (const version)
|
inline |
Access adjacency dict of a node with bounds check (const version)
| [in] | node | The node to look up |
|
inline |
|
inline |
Remove all nodes and edges from the graph.
|
inline |
Check if a node is in the graph.
| [in] | node | The node to check |
|
inline |
Get the degree of a node.
| [in] | node | The node to get the degree for |
|
inline |
Return a vector of all edges as (u, v) pairs.
Each undirected edge is reported once with u < v.
|
inline |
End iterator over nodes.
|
inlinestatic |
For compatible with BGL adaptor.
| [in] | e |
|
inlinestatic |
For compatible with BGL adaptor.
| [in] | e |
|
inline |
Apply a callable to each edge without materializing a vector.
More efficient than edges() when you only need to iterate once, as it avoids allocating the result vector. Each edge (u, v) is yielded once with u < v.
| F | Callable void(const Node&, const Node&) or similar |
| [in] | func | Callable invoked for each edge |
|
inline |
Check if an edge exists between two nodes.
| [in] | node_u | First endpoint |
| [in] | node_v | Second endpoint |
|
inline |
Check if the graph contains a node.
| [in] | node | The node to check |
|
inline |
Check if the graph is directed.
|
inline |
Check if the graph is a multigraph.
|
inline |
|
inline |
Get the number of edges in the graph.
|
inline |
Get the number of nodes in the graph.
|
inline |
Access adjacency dict of a node (non-const version)
| [in] | node | The node to look up |
|
inline |
Access adjacency dict of a node (const version)
| [in] | node | The node to look up |
|
inline |
Get the number of nodes (same as number_of_nodes)
|
inline |
Get the number of nodes (same as number_of_nodes)
| adjlist_outer_dict_factory xnetwork::Graph< _nodeview_t, adjlist_t, adjlist_outer_dict_factory >::_adj |
Adjacency dictionary keyed by node.
| nodeview_t xnetwork::Graph< _nodeview_t, adjlist_t, adjlist_outer_dict_factory >::_node |
Container holding all nodes in the graph.
| size_t xnetwork::Graph< _nodeview_t, adjlist_t, adjlist_outer_dict_factory >::_num_of_edges = 0 |
Number of edges in the graph (cached)