|
nxpp
Header-only graph utilities on top of Boost Graph Library
|
Graph wrapper around Boost Graph Library with Python-inspired helpers. More...
#include <graph.hpp>
Classes | |
| struct | EdgeAttrProxy |
| class | EdgeProxy |
| class | NodeAttrBaseProxy |
| struct | NodeAttrProxy |
| class | NodeProxy |
Public Types | |
| using | NodeType = NodeID |
| using | EdgeWeightType = EdgeWeight |
| using | OutEdgeListSelector = OutEdgeSelector |
| using | VertexListSelector = VertexSelector |
| using | DirectedSelector = typename std::conditional< Directed, boost::bidirectionalS, boost::undirectedS >::type |
| using | VertexProperty = boost::property< boost::vertex_name_t, NodeID, boost::property< boost::vertex_wrapper_index_t, std::size_t > > |
| using | EdgeProperty = typename std::conditional< Weighted, boost::property< boost::edge_weight_t, EdgeWeight, boost::property< boost::edge_index_t, std::size_t > >, boost::property< boost::edge_index_t, std::size_t > >::type |
| using | GraphType = boost::adjacency_list< OutEdgeSelector, VertexSelector, DirectedSelector, VertexProperty, EdgeProperty > |
| using | VertexDesc = typename boost::graph_traits< GraphType >::vertex_descriptor |
| using | EdgeDesc = typename boost::graph_traits< GraphType >::edge_descriptor |
| using | WeightMap = typename built_in_weight_traits< GraphType, Weighted >::map_type |
| using | VertexNameMap = typename boost::property_map< GraphType, boost::vertex_name_t >::type |
| using | WrapperIndexMap = typename boost::property_map< GraphType, boost::vertex_wrapper_index_t >::type |
| using | VertexIndexMap = WrapperIndexMap |
| using | EdgeIdMap = typename boost::property_map< GraphType, boost::edge_index_t >::type |
| using | IdMap = std::map< NodeID, VertexDesc > |
| using | AttrMap = std::map< std::string, std::any > |
| using | NodeAttrStorage = std::map< NodeID, AttrMap > |
| using | EdgeAttrStorage = std::map< std::size_t, AttrMap > |
Public Member Functions | |
| void | add_node (const NodeID &id) |
| Ensures that a node with the given ID exists in the graph. | |
| void | add_nodes_from (const std::vector< NodeID > &nodes) |
| Adds a batch of nodes from a vector of node IDs. | |
| EdgeDesc | get_edge_desc (const NodeID &u, const NodeID &v) const |
| Returns the underlying Boost edge descriptor for an existing edge. | |
| bool | has_edge (const NodeID &u, const NodeID &v) const |
| Returns whether at least one edge exists between two endpoints. | |
| bool | has_edge_id (std::size_t edge_id) const |
| Returns whether an edge with the given wrapper-managed ID exists. | |
| std::vector< std::size_t > | edge_ids () const |
| Returns all wrapper-managed edge IDs currently present in the graph. | |
| std::vector< std::size_t > | edge_ids (const NodeID &u, const NodeID &v) const |
| Returns all wrapper-managed edge IDs between the given endpoints. | |
| std::pair< NodeID, NodeID > | get_edge_endpoints (std::size_t edge_id) const |
| Returns the endpoints of an edge identified by its wrapper-managed ID. | |
|
template<bool W = Weighted> requires (W) | |
| void | add_edge (const NodeID &u, const NodeID &v, EdgeWeight w=1.0) |
|
template<bool W = Weighted> requires (W) | |
| std::size_t | add_edge_with_id (const NodeID &u, const NodeID &v, EdgeWeight w=1.0) |
|
template<bool W = Weighted> requires (!W) | |
| void | add_edge (const NodeID &u, const NodeID &v) |
|
template<bool W = Weighted> requires (!W) | |
| std::size_t | add_edge_with_id (const NodeID &u, const NodeID &v) |
| template<bool W = Weighted> requires (W) | |
| void | add_edge (const NodeID &u, const NodeID &v, EdgeWeight w, const EdgeAttrMap &attrs) |
| Adds or updates a weighted edge and attaches an attribute map. | |
| void | add_edge (const NodeID &u, const NodeID &v, const EdgeAttrMap &attrs) |
| Adds an unweighted edge and attaches an attribute map. | |
|
template<bool W = Weighted> requires (W) | |
| void | add_edge (const NodeID &u, const NodeID &v, EdgeWeight w, const std::pair< std::string, std::any > &attr) |
| void | add_edge (const NodeID &u, const NodeID &v, const std::pair< std::string, std::any > &attr) |
| Adds an unweighted edge and attaches one attribute. | |
|
template<bool W = Weighted> requires (W) | |
| void | add_edge (const NodeID &u, const NodeID &v, EdgeWeight w, std::initializer_list< std::pair< std::string, std::any > > attrs) |
| void | add_edge (const NodeID &u, const NodeID &v, std::initializer_list< std::pair< std::string, std::any > > attrs) |
| Adds an unweighted edge and attaches an initializer-list of attributes. | |
|
template<bool W = Weighted> requires (W) | |
| void | add_edges_from (const std::vector< std::tuple< NodeID, NodeID, EdgeWeight > > &edges) |
| void | add_edges_from (const std::vector< std::pair< NodeID, NodeID > > &edges) |
Adds a batch of unweighted edges from (u, v) pairs. | |
| void | clear () |
| Clears the entire graph and all wrapper-managed metadata. | |
| void | remove_edge (const NodeID &u, const NodeID &v) |
| Removes all edges between two endpoints. | |
| void | remove_edge (std::size_t edge_id) |
| Removes a single edge by its wrapper-managed edge ID. | |
| void | remove_node (const NodeID &u) |
| Removes a node and all of its incident edges. | |
| std::vector< NodeID > | neighbors (const NodeID &u) const |
| Returns the outgoing neighbors of a node. | |
| std::vector< NodeID > | successors (const NodeID &u) const |
| Alias for neighbors(), mainly to mirror directed-graph terminology. | |
| std::vector< NodeID > | predecessors (const NodeID &u) const |
| Returns predecessor nodes for directed graphs. | |
| bool | has_node (const NodeID &u) const |
| Returns whether the graph already contains the given node ID. | |
| bool | has_node_attr (const NodeID &u, const std::string &key) const |
| Returns whether a node has the named attribute. | |
| bool | has_edge_attr (const NodeID &u, const NodeID &v, const std::string &key) const |
| Returns whether an endpoint-selected edge has the named attribute. | |
| bool | has_edge_attr (std::size_t edge_id, const std::string &key) const |
| Returns whether an edge-ID-selected edge has the named attribute. | |
| template<typename T > | |
| T | get_node_attr (const NodeID &u, const std::string &key) const |
| Reads a typed node attribute. | |
| template<typename T > | |
| T | get_edge_attr (const NodeID &u, const NodeID &v, const std::string &key) const |
| Reads a typed edge attribute selected by endpoints. | |
| template<typename T > | |
| T | get_edge_attr (std::size_t edge_id, const std::string &key) const |
| Reads a typed edge attribute selected by edge ID. | |
| template<typename T > | |
| std::optional< T > | try_get_node_attr (const NodeID &u, const std::string &key) const |
| Attempts to read a typed node attribute without throwing. | |
| template<typename T > | |
| std::optional< T > | try_get_edge_attr (const NodeID &u, const NodeID &v, const std::string &key) const |
| Attempts to read a typed edge attribute selected by endpoints. | |
| template<typename T > | |
| std::optional< T > | try_get_edge_attr (std::size_t edge_id, const std::string &key) const |
| Attempts to read a typed edge attribute selected by edge ID. | |
| double | get_edge_numeric_attr (const NodeID &u, const NodeID &v, const std::string &key) const |
| Reads an endpoint-selected edge attribute as a numeric value. | |
| double | get_edge_numeric_attr (std::size_t edge_id, const std::string &key) const |
| Reads an edge attribute as a numeric value selected by edge ID. | |
|
template<bool W = Weighted> requires (W) | |
| EdgeWeight | get_edge_weight (const NodeID &u, const NodeID &v) const |
|
template<bool W = Weighted> requires (W) | |
| EdgeWeight | get_edge_weight (std::size_t edge_id) const |
|
template<bool W = Weighted> requires (W) | |
| void | set_edge_weight (std::size_t edge_id, EdgeWeight w) |
| template<typename T > | |
| void | set_edge_attr (std::size_t edge_id, const std::string &key, const T &value) |
| Stores a typed attribute on an edge identified by edge ID. | |
| std::vector< NodeID > | nodes () const |
| Returns all node IDs currently stored in the graph. | |
| auto | edges () const |
| Returns the public edge list. | |
| std::vector< std::pair< NodeID, NodeID > > | edge_pairs () const |
| Returns all edges as endpoint pairs, ignoring built-in weights. | |
| const GraphType & | get_impl () const |
| Exposes the underlying Boost graph for advanced integrations. | |
| const std::vector< NodeID > & | get_bgl_to_id_map () const |
| Returns the maintained vertex-index-to-node-ID translation table. | |
| const IdMap & | get_id_to_bgl_map () const |
| Returns the maintained node-ID-to-vertex translation table. | |
| const NodeID & | get_node_id (VertexDesc v) const |
| Returns the wrapper-side node ID associated with a Boost vertex descriptor. | |
| std::size_t | get_vertex_index (VertexDesc v) const |
| Returns the wrapper-maintained dense vertex index used by algorithms. | |
| NodeProxy | operator[] (const NodeID &u) |
Returns the proxy used for G[u][v] edge-access syntax. | |
| NodeAttrBaseProxy | node (const NodeID &u) |
Returns the proxy used for G.node(u)[key] node-attribute syntax. | |
| auto | bfs_edges (const NodeID &start) const |
| Returns the tree edges discovered by breadth-first search. | |
| auto | bfs_tree (const NodeID &start) const |
Materializes the breadth-first-search tree rooted at start. | |
| auto | bfs_successors (const NodeID &start) const |
| Groups BFS tree children by their discovered parent. | |
| template<typename Visitor > | |
| void | breadth_first_search (const NodeID &start, Visitor &visitor) const |
| Runs breadth-first search with an object-style visitor. | |
| template<typename OnVertex , typename OnTreeEdge > | |
| void | bfs_visit (const NodeID &start, OnVertex &&on_vertex, OnTreeEdge &&on_tree_edge) const |
| Runs breadth-first search with lightweight callback hooks. | |
| auto | dfs_edges (const NodeID &start) const |
| Returns the tree edges discovered by depth-first search. | |
| auto | dfs_tree (const NodeID &start) const |
Materializes the depth-first-search tree rooted at start. | |
| auto | dfs_predecessors (const NodeID &start) const |
| Returns the DFS predecessor assigned to each discovered node. | |
| auto | dfs_successors (const NodeID &start) const |
| Groups DFS tree children by their discovered parent. | |
| template<typename Visitor > | |
| void | depth_first_search (const NodeID &start, Visitor &visitor) const |
| Runs depth-first search with an object-style visitor. | |
| template<typename OnTreeEdge , typename OnBackEdge > | |
| void | dfs_visit (const NodeID &start, OnTreeEdge &&on_tree_edge, OnBackEdge &&on_back_edge) const |
| Runs depth-first search with lightweight callback hooks. | |
| auto | shortest_path (const NodeID &source_id, const NodeID &target_id) const |
| Computes an unweighted shortest path between two nodes. | |
| auto | shortest_path (const NodeID &source_id, const NodeID &target_id, const std::string &weight) const |
| Computes a shortest path using the built-in edge-weight property. | |
| double | shortest_path_length (const NodeID &source_id, const NodeID &target_id) const |
| Returns the length of an unweighted shortest path. | |
| double | shortest_path_length (const NodeID &source_id, const NodeID &target_id, const std::string &weight) const |
| Returns the length of a shortest path using the built-in edge-weight property. | |
| template<bool W = Weighted> requires (W) | |
| auto | dijkstra_path (const NodeID &source_id, const NodeID &target_id) const |
| Computes the shortest path using the built-in edge-weight property. | |
| template<bool W = Weighted> requires (W) | |
| auto | dijkstra_path (const NodeID &source_id, const NodeID &target_id, const std::string &weight) const |
| Computes the shortest path using the built-in edge-weight property. | |
| template<bool W = Weighted> requires (W) | |
| auto | dijkstra_shortest_paths (const NodeID &source_id) const |
| Returns distances and predecessors for all nodes reachable from a source. | |
| template<bool W = Weighted> requires (W) | |
| auto | dijkstra_path_length (const NodeID &source_id) const |
| Returns built-in-weight shortest-path distances from a source node. | |
| template<bool W = Weighted> requires (W) | |
| auto | dijkstra_path_length (const NodeID &source_id, const NodeID &target_id) const |
| Returns the built-in-weight shortest-path length between two nodes. | |
| template<bool W = Weighted> requires (W) | |
| auto | dijkstra_path_length (const NodeID &source_id, const NodeID &target_id, const std::string &weight) const |
| Returns the shortest-path length using the built-in edge-weight property. | |
| template<bool W = Weighted> requires (W) | |
| auto | bellman_ford_path (const NodeID &source_id, const NodeID &target_id) const |
| Computes a shortest path using Bellman-Ford and built-in weights. | |
| template<bool W = Weighted> requires (W) | |
| auto | bellman_ford_shortest_paths (const NodeID &source_id) const |
| Returns distances and predecessors for all nodes using Bellman-Ford. | |
| template<bool W = Weighted> requires (W) | |
| auto | bellman_ford_path (const NodeID &source_id, const NodeID &target_id, const std::string &weight) const |
| Computes a shortest path using Bellman-Ford and a named edge attribute. | |
| template<bool W = Weighted> requires (W) | |
| auto | bellman_ford_path_length (const NodeID &source_id, const NodeID &target_id) const |
| Returns the Bellman-Ford shortest-path length with built-in weights. | |
| template<bool W = Weighted> requires (W) | |
| auto | bellman_ford_path_length (const NodeID &source_id, const NodeID &target_id, const std::string &weight) const |
| Returns the Bellman-Ford shortest-path length with a named edge attribute. | |
| template<bool W = Weighted> requires (W) | |
| auto | dag_shortest_paths (const NodeID &source_id) const |
| Returns shortest-path distances in a directed acyclic graph. | |
| template<bool W = Weighted> requires (W) | |
| auto | floyd_warshall_all_pairs_shortest_paths () const |
| Returns all-pairs shortest-path distances as a dense matrix. | |
| template<bool W = Weighted> requires (W) | |
| auto | floyd_warshall_all_pairs_shortest_paths_map () const |
| Returns all-pairs shortest-path distances keyed by node IDs. | |
| auto | connected_component_groups () const |
| Groups each connected component as a vector of node IDs. | |
| auto | connected_components () const |
| Returns the number of connected components in an undirected graph. | |
| auto | strongly_connected_component_groups () const |
| Groups each strongly connected component as a vector of node IDs. | |
| auto | strong_component_map () const |
| Returns the component index assigned to each node in a directed graph. | |
| auto | strong_components () const |
| Returns the number of strongly connected components in a directed graph. | |
| auto | connected_component_map () const |
| Returns the connected-component index assigned to each node. | |
| auto | strongly_connected_components () const |
| Alias for strongly_connected_component_groups(). | |
| auto | strongly_connected_component_map () const |
| Alias for strong_component_map(). | |
| auto | strongly_connected_component_roots () const |
| Returns one representative root node for each strong component. | |
| auto | topological_sort () const |
| Returns a topological ordering for a directed acyclic graph. | |
| template<bool W = Weighted> requires (W) | |
| auto | kruskal_minimum_spanning_tree () const |
| Returns the edges selected by Kruskal's minimum-spanning-tree algorithm. | |
| template<bool W = Weighted> requires (W) | |
| auto | prim_minimum_spanning_tree (const NodeID &root_id) const |
| Returns the parent map produced by Prim's minimum-spanning-tree algorithm. | |
| template<bool W = Weighted> requires (W) | |
| auto | minimum_spanning_tree () const |
| Convenience alias for kruskal_minimum_spanning_tree(). | |
| template<bool W = Weighted> requires (W) | |
| auto | minimum_spanning_tree (const NodeID &root_id) const |
Convenience alias for prim_minimum_spanning_tree(root_id). | |
| auto | edmonds_karp_maximum_flow (const NodeID &source_id, const NodeID &target_id, const std::string &capacity_attr="capacity") const |
| Computes a maximum flow using the Edmonds-Karp algorithm. | |
| auto | push_relabel_maximum_flow_result (const NodeID &source_id, const NodeID &target_id, const std::string &capacity_attr="capacity") const |
| Computes a maximum flow using push-relabel and returns edge assignments. | |
| auto | maximum_flow (const NodeID &source_id, const NodeID &target_id, const std::string &capacity_attr="capacity") const |
| Computes the maximum flow value and edge assignments using the named capacity attribute. | |
| auto | minimum_cut (const NodeID &source_id, const NodeID &target_id, const std::string &capacity_attr="capacity") const |
| Computes a minimum cut between source and target using the named capacity attribute. | |
| auto | max_flow_min_cost_cycle_canceling (const NodeID &source_id, const NodeID &target_id, const std::string &capacity_attr="capacity", const std::string &weight_attr="weight") const |
| Computes a max-flow min-cost result using cycle canceling. | |
| long | push_relabel_maximum_flow (const NodeID &source_id, const NodeID &target_id, const std::string &capacity_attr="capacity", const std::string &weight_attr="weight") const |
Runs push-relabel and stages residual state for a later cycle_canceling() call. Any later graph mutation invalidates that staged state. The default "weight" still refers to the built-in edge-weight property. | |
| auto | cycle_canceling (const std::string &weight_attr="weight") const |
| Runs cycle canceling on the previously cached residual network. | |
| auto | successive_shortest_path_nonnegative_weights (const NodeID &source_id, const NodeID &target_id, const std::string &capacity_attr="capacity", const std::string &weight_attr="weight") const |
| Computes a max-flow min-cost result using successive shortest path. | |
| auto | max_flow_min_cost_successive_shortest_path (const NodeID &source_id, const NodeID &target_id, const std::string &capacity_attr="capacity", const std::string &weight_attr="weight") const |
| Convenience alias for successive_shortest_path_nonnegative_weights(). | |
| auto | max_flow_min_cost (const NodeID &source_id, const NodeID &target_id, const std::string &capacity_attr="capacity", const std::string &weight_attr="weight") const |
| Convenience alias for the default max-flow min-cost wrapper. | |
| auto | num_vertices () const |
| Returns the number of vertices currently stored in the graph. | |
| auto | degree_centrality () const |
| Computes normalized degree centrality for every node. | |
| auto | pagerank () const |
| Computes PageRank scores for every node. | |
| auto | betweenness_centrality () const |
| Computes normalized betweenness centrality for every node. | |
Static Public Attributes | |
| static constexpr bool | is_directed = Directed |
| static constexpr bool | has_builtin_edge_weight = Weighted |
Graph wrapper around Boost Graph Library with Python-inspired helpers.
The template parameters control directedness, multigraph support, built-in edge weights, and the underlying Boost selectors. Public methods operate on stable wrapper-side node IDs instead of raw Boost descriptors.
NodeID is expected to be copy-constructible, equality comparable, and orderable through std::less. The core wrapper intentionally relies on ordered translation maps and ordered result containers rather than exposing a public hash-table requirement.
| void nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::add_edge | ( | const NodeID & | u, |
| const NodeID & | v, | ||
| const EdgeAttrMap & | attrs | ||
| ) |
Adds an unweighted edge and attaches an attribute map.
This overload is the attribute-bearing counterpart of the plain unweighted add_edge(u, v) form. In multigraphs it remains endpoint-based convenience API rather than a precise single-edge handle.
| void nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::add_edge | ( | const NodeID & | u, |
| const NodeID & | v, | ||
| EdgeWeight | w, | ||
| const EdgeAttrMap & | attrs | ||
| ) |
Adds or updates a weighted edge and attaches an attribute map.
The built-in weight is stored in the graph edge property, while the supplied attributes are copied into the wrapper-managed edge attribute storage. In multigraphs this remains an endpoint-based convenience form, not a precise single-parallel-edge insertion/update API.
|
inline |
Ensures that a node with the given ID exists in the graph.
This is idempotent: if the node is already present, the call leaves the graph unchanged. Use it when you want to materialize isolated nodes explicitly instead of relying on edge insertion to create them.
Referenced by nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::add_nodes_from(), nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::bfs_tree(), nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::dfs_tree(), nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::node(), nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::NodeAttrProxy::operator=(), and nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::operator[]().
|
inline |
Adds a batch of nodes from a vector of node IDs.
Each element is forwarded to add_node(), so duplicate IDs are ignored in the same way as repeated single-node insertion.
References nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::add_node(), and nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::nodes().
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::bellman_ford_path | ( | const NodeID & | source_id, |
| const NodeID & | target_id | ||
| ) | const |
Computes a shortest path using Bellman-Ford and built-in weights.
| W | Internal enable/disable gate for weighted graph specializations. |
| source_id | Source node ID. |
| target_id | Target node ID. |
std::vector<NodeID> describing the shortest path from source to target. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::bellman_ford_path | ( | const NodeID & | source_id, |
| const NodeID & | target_id, | ||
| const std::string & | weight | ||
| ) | const |
Computes a shortest path using Bellman-Ford and a named edge attribute.
| W | Internal enable/disable gate for weighted graph specializations. |
| source_id | Source node ID. |
| target_id | Target node ID. |
| weight | Name of the edge attribute interpreted as a numeric weight. |
std::vector<NodeID> describing the shortest path from source to target. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::bellman_ford_path_length | ( | const NodeID & | source_id, |
| const NodeID & | target_id | ||
| ) | const |
Returns the Bellman-Ford shortest-path length with built-in weights.
| W | Internal enable/disable gate for weighted graph specializations. |
| source_id | Source node ID. |
| target_id | Target node ID. |
EdgeWeight. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::bellman_ford_path_length | ( | const NodeID & | source_id, |
| const NodeID & | target_id, | ||
| const std::string & | weight | ||
| ) | const |
Returns the Bellman-Ford shortest-path length with a named edge attribute.
| W | Internal enable/disable gate for weighted graph specializations. |
| source_id | Source node ID. |
| target_id | Target node ID. |
| weight | Name of the edge attribute interpreted as a numeric weight. |
EdgeWeight. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::bellman_ford_shortest_paths | ( | const NodeID & | source_id | ) | const |
Returns distances and predecessors for all nodes using Bellman-Ford.
| W | Internal enable/disable gate for weighted graph specializations. |
| source_id | Source node ID. |
distance and predecessor maps keyed by NodeID. References nxpp::SingleSourceShortestPathResult< NodeID, Distance >::distance, and nxpp::SingleSourceShortestPathResult< NodeID, Distance >::predecessor.
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::betweenness_centrality | ( | ) | const |
Computes normalized betweenness centrality for every node.
The current implementation uses a self-contained Brandes shortest-path accumulation pass and normalizes the result with semantics matching betweenness_centrality(G, normalized=True) in NetworkX.
indexed_lookup_map<NodeID, double> keyed by public node ID containing one normalized betweenness-centrality score per node. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::bfs_edges | ( | const NodeID & | start | ) | const |
Returns the tree edges discovered by breadth-first search.
| start | Node ID used as the BFS root. |
std::vector<std::pair<NodeID, NodeID>> containing the ordered BFS tree edges as (parent, child) pairs. | std::runtime_error | If start is not present in the graph. |
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::bfs_successors | ( | const NodeID & | start | ) | const |
Groups BFS tree children by their discovered parent.
Only nodes that actually gain at least one tree child appear in the sparse result map.
| start | Node ID used as the BFS root. |
std::vector<NodeID> of discovered children. | std::runtime_error | If start is not present in the graph. |
References nxpp::bfs_edges().
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::bfs_tree | ( | const NodeID & | start | ) | const |
Materializes the breadth-first-search tree rooted at start.
The returned graph contains the root node and each tree edge reported by bfs_edges.
| start | Node ID used as the BFS root. |
Graph<NodeID, double, Directed> containing only the BFS tree. | std::runtime_error | If start is not present in the graph. |
References nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::add_node(), and nxpp::bfs_edges().
| void nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::bfs_visit | ( | const NodeID & | start, |
| OnVertex && | on_vertex, | ||
| OnTreeEdge && | on_tree_edge | ||
| ) | const |
Runs breadth-first search with lightweight callback hooks.
This is a convenience wrapper over breadth_first_search that avoids defining a dedicated visitor type when only vertex and tree-edge events are needed.
| OnVertex | Callback invoked as on_vertex(u). |
| OnTreeEdge | Callback invoked as on_tree_edge(u, v). |
| start | Node ID used as the BFS root. |
| on_vertex | Callback for discovered vertices. |
| on_tree_edge | Callback for BFS tree edges. |
| std::runtime_error | If start is not present in the graph. |
References nxpp::breadth_first_search().
| void nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::breadth_first_search | ( | const NodeID & | start, |
| Visitor & | visitor | ||
| ) | const |
Runs breadth-first search with an object-style visitor.
The visitor may implement wrapper-level hooks such as examine_vertex(u, G) and tree_edge(u, v, G).
| Visitor | Visitor object type accepted by the wrapper dispatcher. |
| start | Node ID used as the BFS root. |
| visitor | Visitor instance that receives traversal callbacks. |
| std::runtime_error | If start is not present in the graph. |
|
inline |
Clears the entire graph and all wrapper-managed metadata.
After this call, nodes, edges, edge IDs, built-in weights, attributes, and translation tables are reset to the same logical state as a freshly default-constructed graph.
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::cycle_canceling | ( | const std::string & | weight_attr = "weight" | ) | const |
Runs cycle canceling on the previously cached residual network.
Any graph mutation after push_relabel_maximum_flow(...) invalidates the staged residual state, so callers must rerun the push-relabel stage before calling this function again.
| weight_attr | Name of the numeric edge attribute used as cost. The default "weight" refers to the built-in edge-weight property. |
long. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::dag_shortest_paths | ( | const NodeID & | source_id | ) | const |
Returns shortest-path distances in a directed acyclic graph.
| W | Internal enable/disable gate for weighted graph specializations. |
| source_id | Source node ID. |
distance and predecessor maps keyed by NodeID. References nxpp::SingleSourceShortestPathResult< NodeID, Distance >::distance, and nxpp::SingleSourceShortestPathResult< NodeID, Distance >::predecessor.
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::degree_centrality | ( | ) | const |
Computes normalized degree centrality for every node.
For undirected graphs this uses the standard degree. For directed graphs it uses in_degree + out_degree. The result is normalized by n - 1, matching the usual NetworkX-style convention.
indexed_lookup_map<NodeID, double> keyed by public node ID that stores one normalized degree-centrality score per node. | void nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::depth_first_search | ( | const NodeID & | start, |
| Visitor & | visitor | ||
| ) | const |
Runs depth-first search with an object-style visitor.
The visitor may implement wrapper-level hooks such as tree_edge(u, v, G) and back_edge(u, v, G).
| Visitor | Visitor object type accepted by the wrapper dispatcher. |
| start | Node ID used as the DFS root. |
| visitor | Visitor instance that receives traversal callbacks. |
| std::runtime_error | If start is not present in the graph. |
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::dfs_edges | ( | const NodeID & | start | ) | const |
Returns the tree edges discovered by depth-first search.
| start | Node ID used as the DFS root. |
std::vector<std::pair<NodeID, NodeID>> containing the ordered DFS tree edges as (parent, child) pairs. | std::runtime_error | If start is not present in the graph. |
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::dfs_predecessors | ( | const NodeID & | start | ) | const |
Returns the DFS predecessor assigned to each discovered node.
The sparse result omits the root node and any node not reached from start.
| start | Node ID used as the DFS root. |
NodeID. | std::runtime_error | If start is not present in the graph. |
References nxpp::dfs_edges().
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::dfs_successors | ( | const NodeID & | start | ) | const |
Groups DFS tree children by their discovered parent.
Only nodes that actually gain at least one tree child appear in the sparse result map.
| start | Node ID used as the DFS root. |
std::vector<NodeID> of discovered children. | std::runtime_error | If start is not present in the graph. |
References nxpp::dfs_edges().
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::dfs_tree | ( | const NodeID & | start | ) | const |
Materializes the depth-first-search tree rooted at start.
The returned graph contains the root node and each tree edge reported by dfs_edges.
| start | Node ID used as the DFS root. |
Graph<NodeID, double, Directed> containing only the DFS tree. | std::runtime_error | If start is not present in the graph. |
References nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::add_node(), and nxpp::dfs_edges().
| void nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::dfs_visit | ( | const NodeID & | start, |
| OnTreeEdge && | on_tree_edge, | ||
| OnBackEdge && | on_back_edge | ||
| ) | const |
Runs depth-first search with lightweight callback hooks.
This is a convenience wrapper over depth_first_search that avoids defining a dedicated visitor type when only tree-edge and back-edge events are needed.
| OnTreeEdge | Callback invoked as on_tree_edge(u, v). |
| OnBackEdge | Callback invoked as on_back_edge(u, v). |
| start | Node ID used as the DFS root. |
| on_tree_edge | Callback for DFS tree edges. |
| on_back_edge | Callback for DFS back edges. |
| std::runtime_error | If start is not present in the graph. |
References nxpp::depth_first_search().
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::dijkstra_path | ( | const NodeID & | source_id, |
| const NodeID & | target_id | ||
| ) | const |
Computes the shortest path using the built-in edge-weight property.
| W | Internal enable/disable gate for weighted graph specializations. |
| source_id | Source node ID. |
| target_id | Target node ID. |
std::vector<NodeID> describing the shortest path from source to target. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::dijkstra_path | ( | const NodeID & | source_id, |
| const NodeID & | target_id, | ||
| const std::string & | weight | ||
| ) | const |
Computes the shortest path using the built-in edge-weight property.
This overload accepts the compatibility-shaped "weight" name, not an arbitrary user-defined weight attribute.
| W | Internal enable/disable gate for weighted graph specializations. |
| source_id | Source node ID. |
| target_id | Target node ID. |
| weight | Compatibility name for the built-in edge-weight property. |
std::vector<NodeID> describing the shortest path from source to target. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::dijkstra_path_length | ( | const NodeID & | source_id | ) | const |
Returns built-in-weight shortest-path distances from a source node.
| W | Internal enable/disable gate for weighted graph specializations. |
| source_id | Source node ID. |
std::map<NodeID, EdgeWeight> of distances from source_id. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::dijkstra_path_length | ( | const NodeID & | source_id, |
| const NodeID & | target_id | ||
| ) | const |
Returns the built-in-weight shortest-path length between two nodes.
| W | Internal enable/disable gate for weighted graph specializations. |
| source_id | Source node ID. |
| target_id | Target node ID. |
EdgeWeight. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::dijkstra_path_length | ( | const NodeID & | source_id, |
| const NodeID & | target_id, | ||
| const std::string & | weight | ||
| ) | const |
Returns the shortest-path length using the built-in edge-weight property.
This overload accepts the compatibility-shaped "weight" name, not an arbitrary user-defined weight attribute.
| W | Internal enable/disable gate for weighted graph specializations. |
| source_id | Source node ID. |
| target_id | Target node ID. |
| weight | Compatibility name for the built-in edge-weight property. |
EdgeWeight. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::dijkstra_shortest_paths | ( | const NodeID & | source_id | ) | const |
Returns distances and predecessors for all nodes reachable from a source.
| W | Internal enable/disable gate for weighted graph specializations. |
| source_id | Source node ID. |
distance and predecessor maps keyed by NodeID. References nxpp::SingleSourceShortestPathResult< NodeID, Distance >::distance, and nxpp::SingleSourceShortestPathResult< NodeID, Distance >::predecessor.
|
inline |
Returns the public edge list.
Weighted graphs expose (u, v, w) tuples, while unweighted graphs expose (u, v) pairs. The return type follows the Weighted template flag.
Referenced by nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::add_edges_from().
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::edmonds_karp_maximum_flow | ( | const NodeID & | source_id, |
| const NodeID & | target_id, | ||
| const std::string & | capacity_attr = "capacity" |
||
| ) | const |
Computes a maximum flow using the Edmonds-Karp algorithm.
| source_id | Source node ID. |
| target_id | Sink node ID. |
| capacity_attr | Name of the numeric edge attribute used as capacity. |
edge_id-keyed flow assignment. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::floyd_warshall_all_pairs_shortest_paths | ( | ) | const |
Returns all-pairs shortest-path distances as a dense matrix.
The returned matrix follows the wrapper's stable node-ordering, so row and column positions correspond to the order reported by nodes.
| W | Internal enable/disable gate for weighted graph specializations. |
std::vector<std::vector<EdgeWeight>> shortest-path matrix ordered by the stable node order reported by nodes. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::floyd_warshall_all_pairs_shortest_paths_map | ( | ) | const |
Returns all-pairs shortest-path distances keyed by node IDs.
This wrapper expands the dense Floyd-Warshall matrix into nested ordered maps so callers can address results directly by source and target ID.
| W | Internal enable/disable gate for weighted graph specializations. |
std::map<NodeID, std::map<NodeID, EdgeWeight>> keyed first by source node and then by target node. | T nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::get_edge_attr | ( | const NodeID & | u, |
| const NodeID & | v, | ||
| const std::string & | key | ||
| ) | const |
Reads a typed edge attribute selected by endpoints.
Prefer the edge-id overload in multigraphs when you need stable per-parallel-edge access.
| T nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::get_edge_attr | ( | std::size_t | edge_id, |
| const std::string & | key | ||
| ) | const |
Reads a typed edge attribute selected by edge ID.
This is the precise typed read path for multigraph edge metadata.
|
inline |
Returns the underlying Boost edge descriptor for an existing edge.
This is mainly for advanced integrations with raw Boost algorithms. Most users should prefer the higher-level wrapper methods and edge-id helpers.
Referenced by nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::EdgeAttrProxy::operator=().
| double nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::get_edge_numeric_attr | ( | const NodeID & | u, |
| const NodeID & | v, | ||
| const std::string & | key | ||
| ) | const |
Reads an endpoint-selected edge attribute as a numeric value.
The special key "weight" resolves to the built-in edge-weight property when the graph is weighted. In multigraphs this remains an endpoint-based convenience lookup rather than a precise single-edge read path.
| T nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::get_node_attr | ( | const NodeID & | u, |
| const std::string & | key | ||
| ) | const |
Reads a typed node attribute.
This throws if the node has no attributes, the key is missing, or the stored value cannot be converted to the requested type.
|
inline |
Returns whether at least one edge exists between two endpoints.
In multigraphs this answers an existence question only: it does not tell you which parallel edge matched. Use edge_ids(u, v) for precise parallel-edge inspection.
Referenced by nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::EdgeAttrProxy::operator=().
| bool nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::has_edge_attr | ( | const NodeID & | u, |
| const NodeID & | v, | ||
| const std::string & | key | ||
| ) | const |
Returns whether an endpoint-selected edge has the named attribute.
In multigraphs this follows the same (u, v) caveat as the other endpoint-based edge accessors and should not be treated as precise parallel-edge identification.
| bool nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::has_node_attr | ( | const NodeID & | u, |
| const std::string & | key | ||
| ) | const |
Returns whether a node has the named attribute.
Missing nodes are treated as "attribute not present" rather than as an exceptional case.
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::kruskal_minimum_spanning_tree | ( | ) | const |
Returns the edges selected by Kruskal's minimum-spanning-tree algorithm.
| W | Internal enable/disable gate for weighted graph specializations. |
std::vector<std::pair<NodeID, NodeID>> containing the selected spanning-tree edges as (u, v) pairs. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::max_flow_min_cost | ( | const NodeID & | source_id, |
| const NodeID & | target_id, | ||
| const std::string & | capacity_attr = "capacity", |
||
| const std::string & | weight_attr = "weight" |
||
| ) | const |
Convenience alias for the default max-flow min-cost wrapper.
| source_id | Source node ID. |
| target_id | Sink node ID. |
| capacity_attr | Name of the numeric edge attribute used as capacity. |
| weight_attr | Name of the numeric edge attribute used as cost. The default "weight" refers to the built-in edge-weight property. |
edge_id-keyed flow assignment. References nxpp::max_flow_min_cost_cycle_canceling().
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::max_flow_min_cost_cycle_canceling | ( | const NodeID & | source_id, |
| const NodeID & | target_id, | ||
| const std::string & | capacity_attr = "capacity", |
||
| const std::string & | weight_attr = "weight" |
||
| ) | const |
Computes a max-flow min-cost result using cycle canceling.
| source_id | Source node ID. |
| target_id | Sink node ID. |
| capacity_attr | Name of the numeric edge attribute used as capacity. |
| weight_attr | Name of the numeric edge attribute used as cost. The default "weight" refers to the built-in edge-weight property. |
edge_id-keyed flow assignment. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::max_flow_min_cost_successive_shortest_path | ( | const NodeID & | source_id, |
| const NodeID & | target_id, | ||
| const std::string & | capacity_attr = "capacity", |
||
| const std::string & | weight_attr = "weight" |
||
| ) | const |
Convenience alias for successive_shortest_path_nonnegative_weights().
| source_id | Source node ID. |
| target_id | Sink node ID. |
| capacity_attr | Name of the numeric edge attribute used as capacity. |
| weight_attr | Name of the numeric edge attribute used as cost. The default "weight" refers to the built-in edge-weight property. |
edge_id-keyed flow assignment. References nxpp::successive_shortest_path_nonnegative_weights().
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::maximum_flow | ( | const NodeID & | source_id, |
| const NodeID & | target_id, | ||
| const std::string & | capacity_attr = "capacity" |
||
| ) | const |
Computes the maximum flow value and edge assignments using the named capacity attribute.
| source_id | Source node ID. |
| target_id | Sink node ID. |
| capacity_attr | Name of the numeric edge attribute used as capacity. |
edge_id-keyed flow assignment. References nxpp::edmonds_karp_maximum_flow().
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::minimum_cut | ( | const NodeID & | source_id, |
| const NodeID & | target_id, | ||
| const std::string & | capacity_attr = "capacity" |
||
| ) | const |
Computes a minimum cut between source and target using the named capacity attribute.
| source_id | Source node ID. |
| target_id | Sink node ID. |
| capacity_attr | Name of the numeric edge attribute used as capacity. |
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::minimum_spanning_tree | ( | ) | const |
Convenience alias for kruskal_minimum_spanning_tree().
| W | Internal enable/disable gate for weighted graph specializations. |
std::vector<std::pair<NodeID, NodeID>> containing the selected spanning-tree edges as (u, v) pairs. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::minimum_spanning_tree | ( | const NodeID & | root_id | ) | const |
Convenience alias for prim_minimum_spanning_tree(root_id).
| W | Internal enable/disable gate for weighted graph specializations. |
| root_id | Root node used to seed Prim's algorithm. |
std::map<NodeID, NodeID> parent map for the spanning tree.
|
inline |
Returns the outgoing neighbors of a node.
For undirected graphs this is the standard adjacency view. For directed graphs this corresponds to successor nodes.
Referenced by nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::successors().
|
inline |
Returns the proxy used for G.node(u)[key] node-attribute syntax.
The node is created implicitly when it does not exist yet.
References nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::add_node(), and nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::has_node().
|
inline |
Returns all node IDs currently stored in the graph.
The order follows the wrapper-maintained vertex order used by the public API helpers.
Referenced by nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::add_nodes_from().
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::num_vertices | ( | ) | const |
Returns the number of vertices currently stored in the graph.
int.
|
inline |
Returns the proxy used for G[u][v] edge-access syntax.
This keeps the NetworkX-inspired indexing style available for writes and convenience reads on existing-graph operations.
As part of the wrapper's write-creates policy, missing node u is created before the proxy is returned. Chained write forms such as G[u][v] = ... and G[u][v][key] = ... may then create the edge as well. Pure-read helpers such as has_node(...), has_edge(...), checked get_* / try_get_* accessors, traversal reads, and shortest- path reads do not create implicitly.
References nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::add_node(), and nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::has_node().
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::pagerank | ( | ) | const |
Computes PageRank scores for every node.
The current wrapper uses a small fixed-iteration implementation with damping factor 0.85 and explicit redistribution of dangling-node mass. It is intentionally conservative and returns a ready-to-consume result keyed by public node ID instead of exposing lower-level property-map plumbing.
indexed_lookup_map<NodeID, double> keyed by public node ID containing one PageRank score per node.
|
inline |
Returns predecessor nodes for directed graphs.
For undirected graphs this falls back to the ordinary adjacency view, so the result matches neighbors(u).
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::prim_minimum_spanning_tree | ( | const NodeID & | root_id | ) | const |
Returns the parent map produced by Prim's minimum-spanning-tree algorithm.
| W | Internal enable/disable gate for weighted graph specializations. |
| root_id | Root node used to seed Prim's algorithm. |
std::map<NodeID, NodeID> parent map for the spanning tree. | auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::push_relabel_maximum_flow_result | ( | const NodeID & | source_id, |
| const NodeID & | target_id, | ||
| const std::string & | capacity_attr = "capacity" |
||
| ) | const |
Computes a maximum flow using push-relabel and returns edge assignments.
| source_id | Source node ID. |
| target_id | Sink node ID. |
| capacity_attr | Name of the numeric edge attribute used as capacity. |
edge_id-keyed flow assignment.
|
inline |
Removes all edges between two endpoints.
In simple graphs this removes the unique matching edge. In multigraphs it removes every parallel edge between the same endpoints and cleans the associated wrapper-managed edge attributes.
| std::runtime_error | If either node is missing or no such edge exists. |
| void nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::remove_edge | ( | std::size_t | edge_id | ) |
Removes a single edge by its wrapper-managed edge ID.
This is the precise removal form to prefer in multigraphs.
|
inline |
Removes a node and all of its incident edges.
Wrapper-side node/edge attributes and maintained translation/index maps are updated too, so the graph stays internally consistent after descriptor remapping.
| std::runtime_error | If the node is not present. |
| void nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::set_edge_attr | ( | std::size_t | edge_id, |
| const std::string & | key, | ||
| const T & | value | ||
| ) |
Stores a typed attribute on an edge identified by edge ID.
String-like values are normalized through the wrapper's attribute storage helpers in the same way as other public attribute APIs.
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::shortest_path | ( | const NodeID & | source_id, |
| const NodeID & | target_id | ||
| ) | const |
Computes an unweighted shortest path between two nodes.
| source_id | Source node ID. |
| target_id | Target node ID. |
std::vector<NodeID> describing the path from source to target. | std::runtime_error | If either node is missing or the target is unreachable. |
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::shortest_path | ( | const NodeID & | source_id, |
| const NodeID & | target_id, | ||
| const std::string & | weight | ||
| ) | const |
Computes a shortest path using the built-in edge-weight property.
This overload accepts the compatibility-shaped "weight" name, but it does not support arbitrary user-defined weight keys.
| source_id | Source node ID. |
| target_id | Target node ID. |
| weight | Compatibility name for the built-in edge-weight property. |
std::vector<NodeID> describing the path from source to target. | std::runtime_error | If either node is missing, the target is unreachable, or the weight name is unsupported. |
References nxpp::shortest_path().
| double nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::shortest_path_length | ( | const NodeID & | source_id, |
| const NodeID & | target_id | ||
| ) | const |
Returns the length of an unweighted shortest path.
| source_id | Source node ID. |
| target_id | Target node ID. |
double, measured in edge count. | std::runtime_error | If either node is missing or the target is unreachable. |
References nxpp::shortest_path().
| double nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::shortest_path_length | ( | const NodeID & | source_id, |
| const NodeID & | target_id, | ||
| const std::string & | weight | ||
| ) | const |
Returns the length of a shortest path using the built-in edge-weight property.
This overload accepts the compatibility-shaped "weight" name, but it does not support arbitrary user-defined weight keys.
| source_id | Source node ID. |
| target_id | Target node ID. |
| weight | Compatibility name for the built-in edge-weight property. |
double. | std::runtime_error | If either node is missing, the target is unreachable, or the weight name is unsupported. |
References nxpp::shortest_path_length().
| auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::successive_shortest_path_nonnegative_weights | ( | const NodeID & | source_id, |
| const NodeID & | target_id, | ||
| const std::string & | capacity_attr = "capacity", |
||
| const std::string & | weight_attr = "weight" |
||
| ) | const |
Computes a max-flow min-cost result using successive shortest path.
| source_id | Source node ID. |
| target_id | Sink node ID. |
| capacity_attr | Name of the numeric edge attribute used as capacity. |
| weight_attr | Name of the numeric edge attribute used as cost. The default "weight" refers to the built-in edge-weight property. |
edge_id-keyed flow assignment. | std::optional< T > nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::try_get_edge_attr | ( | const NodeID & | u, |
| const NodeID & | v, | ||
| const std::string & | key | ||
| ) | const |
Attempts to read a typed edge attribute selected by endpoints.
Returns std::nullopt instead of throwing when the edge, key, or type does not match. In multigraphs this remains an endpoint-based convenience lookup rather than a precise single-edge read path.
| std::optional< T > nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::try_get_node_attr | ( | const NodeID & | u, |
| const std::string & | key | ||
| ) | const |
Attempts to read a typed node attribute without throwing.
Returns std::nullopt for missing nodes, missing keys, and type mismatches.