|
| | DiGraphS (const nodeview_t &Nodes) |
| | Construct a directed graph from a node container.
|
| |
| | DiGraphS (uint32_t num_nodes) |
| | Construct a directed graph with a given number of integer nodes.
|
| |
| auto | adj () const |
| | Get adjacency mapping (successors) of the directed graph (const version)
|
| |
| auto | succ () const |
| | Get the successors mapping (same as adj)
|
| |
| 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 a directed 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)
|
| |
| template<typename T > |
| auto | add_edge (const Node &node_u, const Node &node_v, const T &data) |
| | Add an edge between two nodes with data.
|
| |
| 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_successor (const Node &node_u, const Node &node_v) const -> bool |
| | Check if a node has a specific successor.
|
| |
| auto | successors (const Node &node) -> auto & |
| | Get iterator over successors of a node (non-const)
|
| |
| auto | successors (const Node &node) const -> const auto & |
| | Get iterator over successors of a node (const)
|
| |
| auto | degree (const Node &node) const |
| | Get the out-degree of a node in the directed graph.
|
| |
| auto | number_of_edges () const -> size_t |
| | Get the number of edges in the directed graph.
|
| |
| auto | clear () |
| | Remove all nodes and edges from the graph.
|
| |
| auto | is_multigraph () const |
| | Check if the graph is a multigraph.
|
| |
| auto | is_directed () const |
| | Check if the graph is directed.
|
| |
| | 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.
|
| |
Directed graph with arbitrary node types.
A DiGraphS stores nodes and edges with optional data or attributes. Directed edges are stored. Self loops are allowed but multiple (parallel) edges are not. Inherits from the undirected Graph base class.
- Template Parameters
-
| nodeview_t | The node container type |
| adjlist_t | The adjacency list type |
| adjlist_outer_dict_factory | The outer dict factory |
Add a directed edge between two nodes (for simple key type, SFINAE)
Add an edge between node_u and node_v.
The nodes node_u and node_v will be automatically added if (they are not already : the graph.
Edge attributes can be specified with keywords or by directly accessing the edge"s attribute dictionary. See examples below.
Parameters
node_u, node_v : nodes Nodes can be, for example, strings or numbers. Nodes must be hashable (and not None) C++ objects.
See Also
add_edges_from : add a collection of edges
Notes
Adding an edge that already exists updates the edge data.
Many XNetwork algorithms designed for weighted graphs use an edge attribute (by default weight) to hold a numerical value.
Examples
The following all add the edge e=(1, 2) to graph gra) {
> gra = xnetwork::DiGraphS() // or DiGraph, MultiGraph,
MultiDiGraph, etc > e = (1, 2); > gra.add_edge(1, 2) // explicit two-node form > gra.add_edges_from([(1, 2)]); // add edges from iterable container
Associate data to edges using keywords) {
> gra.add_edge(1, 2);
For non-string attribute keys, use subscript notation.
> gra.add_edge(1, 2);
> gra[1][2].update({0: 5});
> gra.edges()[1, 2].update({0: 5});
- Template Parameters
-
| U | Key type parameter for SFINAE dispatch |
- Parameters
-
| [in] | node_u | Source node |
| [in] | node_v | Target node |