nxpp
Header-only graph utilities on top of Boost Graph Library
Loading...
Searching...
No Matches
nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector > Class Template Reference

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 >
get_node_attr (const NodeID &u, const std::string &key) const
 Reads a typed node attribute.
 
template<typename 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 >
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
 

Detailed Description

template<typename NodeID = std::string, typename EdgeWeight = double, bool Directed = false, bool Multi = false, bool Weighted = true, typename OutEdgeSelector = boost::vecS, typename VertexSelector = boost::vecS>
class nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >

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.

Member Function Documentation

◆ add_edge() [1/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

◆ add_edge() [2/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

◆ add_node()

template<typename NodeID = std::string, typename EdgeWeight = double, bool Directed = false, bool Multi = false, bool Weighted = true, typename OutEdgeSelector = boost::vecS, typename VertexSelector = boost::vecS>
void nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::add_node ( const NodeID &  id)
inline

◆ add_nodes_from()

template<typename NodeID = std::string, typename EdgeWeight = double, bool Directed = false, bool Multi = false, bool Weighted = true, typename OutEdgeSelector = boost::vecS, typename VertexSelector = boost::vecS>
void nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::add_nodes_from ( const std::vector< NodeID > &  nodes)
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().

◆ bellman_ford_path() [1/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Parameters
source_idSource node ID.
target_idTarget node ID.
Returns
A std::vector<NodeID> describing the shortest path from source to target.

◆ bellman_ford_path() [2/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Parameters
source_idSource node ID.
target_idTarget node ID.
weightName of the edge attribute interpreted as a numeric weight.
Returns
A std::vector<NodeID> describing the shortest path from source to target.

◆ bellman_ford_path_length() [1/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Parameters
source_idSource node ID.
target_idTarget node ID.
Returns
The shortest-path distance as EdgeWeight.

◆ bellman_ford_path_length() [2/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Parameters
source_idSource node ID.
target_idTarget node ID.
weightName of the edge attribute interpreted as a numeric weight.
Returns
The shortest-path distance as EdgeWeight.

◆ bellman_ford_shortest_paths()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Parameters
source_idSource node ID.
Returns
A SingleSourceShortestPathResult carrying ordered distance and predecessor maps keyed by NodeID.

References nxpp::SingleSourceShortestPathResult< NodeID, Distance >::distance, and nxpp::SingleSourceShortestPathResult< NodeID, Distance >::predecessor.

◆ betweenness_centrality()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Returns
An indexed_lookup_map<NodeID, double> keyed by public node ID containing one normalized betweenness-centrality score per node.

◆ bfs_edges()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
startNode ID used as the BFS root.
Returns
A std::vector<std::pair<NodeID, NodeID>> containing the ordered BFS tree edges as (parent, child) pairs.
Exceptions
std::runtime_errorIf start is not present in the graph.

◆ bfs_successors()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
startNode ID used as the BFS root.
Returns
A sparse node-indexed map from each BFS parent to a std::vector<NodeID> of discovered children.
Exceptions
std::runtime_errorIf start is not present in the graph.

References nxpp::bfs_edges().

◆ bfs_tree()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
startNode ID used as the BFS root.
Returns
A Graph<NodeID, double, Directed> containing only the BFS tree.
Exceptions
std::runtime_errorIf start is not present in the graph.

References nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::add_node(), and nxpp::bfs_edges().

◆ bfs_visit()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
template<typename OnVertex , typename OnTreeEdge >
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.

Template Parameters
OnVertexCallback invoked as on_vertex(u).
OnTreeEdgeCallback invoked as on_tree_edge(u, v).
Parameters
startNode ID used as the BFS root.
on_vertexCallback for discovered vertices.
on_tree_edgeCallback for BFS tree edges.
Exceptions
std::runtime_errorIf start is not present in the graph.

References nxpp::breadth_first_search().

◆ breadth_first_search()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
template<typename Visitor >
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).

Template Parameters
VisitorVisitor object type accepted by the wrapper dispatcher.
Parameters
startNode ID used as the BFS root.
visitorVisitor instance that receives traversal callbacks.
Exceptions
std::runtime_errorIf start is not present in the graph.

◆ clear()

template<typename NodeID = std::string, typename EdgeWeight = double, bool Directed = false, bool Multi = false, bool Weighted = true, typename OutEdgeSelector = boost::vecS, typename VertexSelector = boost::vecS>
void nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::clear ( )
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.

◆ cycle_canceling()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
weight_attrName of the numeric edge attribute used as cost. The default "weight" refers to the built-in edge-weight property.
Returns
The total min-cost value after cycle canceling as long.

◆ dag_shortest_paths()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Parameters
source_idSource node ID.
Returns
A SingleSourceShortestPathResult carrying ordered distance and predecessor maps keyed by NodeID.

References nxpp::SingleSourceShortestPathResult< NodeID, Distance >::distance, and nxpp::SingleSourceShortestPathResult< NodeID, Distance >::predecessor.

◆ degree_centrality()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Returns
An indexed_lookup_map<NodeID, double> keyed by public node ID that stores one normalized degree-centrality score per node.

◆ depth_first_search()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
template<typename Visitor >
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).

Template Parameters
VisitorVisitor object type accepted by the wrapper dispatcher.
Parameters
startNode ID used as the DFS root.
visitorVisitor instance that receives traversal callbacks.
Exceptions
std::runtime_errorIf start is not present in the graph.

◆ dfs_edges()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
startNode ID used as the DFS root.
Returns
A std::vector<std::pair<NodeID, NodeID>> containing the ordered DFS tree edges as (parent, child) pairs.
Exceptions
std::runtime_errorIf start is not present in the graph.

◆ dfs_predecessors()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
startNode ID used as the DFS root.
Returns
A sparse node-indexed map from each discovered node to its parent NodeID.
Exceptions
std::runtime_errorIf start is not present in the graph.

References nxpp::dfs_edges().

◆ dfs_successors()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
startNode ID used as the DFS root.
Returns
A sparse node-indexed map from each DFS parent to a std::vector<NodeID> of discovered children.
Exceptions
std::runtime_errorIf start is not present in the graph.

References nxpp::dfs_edges().

◆ dfs_tree()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
startNode ID used as the DFS root.
Returns
A Graph<NodeID, double, Directed> containing only the DFS tree.
Exceptions
std::runtime_errorIf start is not present in the graph.

References nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::add_node(), and nxpp::dfs_edges().

◆ dfs_visit()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
template<typename OnTreeEdge , typename OnBackEdge >
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.

Template Parameters
OnTreeEdgeCallback invoked as on_tree_edge(u, v).
OnBackEdgeCallback invoked as on_back_edge(u, v).
Parameters
startNode ID used as the DFS root.
on_tree_edgeCallback for DFS tree edges.
on_back_edgeCallback for DFS back edges.
Exceptions
std::runtime_errorIf start is not present in the graph.

References nxpp::depth_first_search().

◆ dijkstra_path() [1/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Parameters
source_idSource node ID.
target_idTarget node ID.
Returns
A std::vector<NodeID> describing the shortest path from source to target.

◆ dijkstra_path() [2/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Parameters
source_idSource node ID.
target_idTarget node ID.
weightCompatibility name for the built-in edge-weight property.
Returns
A std::vector<NodeID> describing the shortest path from source to target.

◆ dijkstra_path_length() [1/3]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Parameters
source_idSource node ID.
Returns
An ordered std::map<NodeID, EdgeWeight> of distances from source_id.

◆ dijkstra_path_length() [2/3]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Parameters
source_idSource node ID.
target_idTarget node ID.
Returns
The shortest-path distance as EdgeWeight.

◆ dijkstra_path_length() [3/3]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Parameters
source_idSource node ID.
target_idTarget node ID.
weightCompatibility name for the built-in edge-weight property.
Returns
The shortest-path distance as EdgeWeight.

◆ dijkstra_shortest_paths()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Parameters
source_idSource node ID.
Returns
A SingleSourceShortestPathResult carrying ordered distance and predecessor maps keyed by NodeID.

References nxpp::SingleSourceShortestPathResult< NodeID, Distance >::distance, and nxpp::SingleSourceShortestPathResult< NodeID, Distance >::predecessor.

◆ edges()

template<typename NodeID = std::string, typename EdgeWeight = double, bool Directed = false, bool Multi = false, bool Weighted = true, typename OutEdgeSelector = boost::vecS, typename VertexSelector = boost::vecS>
auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::edges ( ) const
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().

◆ edmonds_karp_maximum_flow()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
source_idSource node ID.
target_idSink node ID.
capacity_attrName of the numeric edge attribute used as capacity.
Returns
A MaximumFlowResult containing the total flow value and the endpoint-keyed convenience flow view plus the precise edge_id-keyed flow assignment.

◆ floyd_warshall_all_pairs_shortest_paths()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Returns
A dense std::vector<std::vector<EdgeWeight>> shortest-path matrix ordered by the stable node order reported by nodes.

◆ floyd_warshall_all_pairs_shortest_paths_map()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Returns
A nested std::map<NodeID, std::map<NodeID, EdgeWeight>> keyed first by source node and then by target node.

◆ get_edge_attr() [1/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
template<typename T >
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.

◆ get_edge_attr() [2/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
template<typename T >
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.

◆ get_edge_desc()

template<typename NodeID = std::string, typename EdgeWeight = double, bool Directed = false, bool Multi = false, bool Weighted = true, typename OutEdgeSelector = boost::vecS, typename VertexSelector = boost::vecS>
EdgeDesc nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::get_edge_desc ( const NodeID &  u,
const NodeID &  v 
) const
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=().

◆ get_edge_numeric_attr()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

◆ get_node_attr()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
template<typename T >
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.

◆ has_edge()

template<typename NodeID = std::string, typename EdgeWeight = double, bool Directed = false, bool Multi = false, bool Weighted = true, typename OutEdgeSelector = boost::vecS, typename VertexSelector = boost::vecS>
bool nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::has_edge ( const NodeID &  u,
const NodeID &  v 
) const
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=().

◆ has_edge_attr()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

◆ has_node_attr()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

◆ kruskal_minimum_spanning_tree()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Returns
A std::vector<std::pair<NodeID, NodeID>> containing the selected spanning-tree edges as (u, v) pairs.

◆ max_flow_min_cost()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
source_idSource node ID.
target_idSink node ID.
capacity_attrName of the numeric edge attribute used as capacity.
weight_attrName of the numeric edge attribute used as cost. The default "weight" refers to the built-in edge-weight property.
Returns
A MinCostMaxFlowResult containing total flow, total cost, the endpoint-keyed convenience flow view, and the precise edge_id-keyed flow assignment.

References nxpp::max_flow_min_cost_cycle_canceling().

◆ max_flow_min_cost_cycle_canceling()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
source_idSource node ID.
target_idSink node ID.
capacity_attrName of the numeric edge attribute used as capacity.
weight_attrName of the numeric edge attribute used as cost. The default "weight" refers to the built-in edge-weight property.
Returns
A MinCostMaxFlowResult containing total flow, total cost, the endpoint-keyed convenience flow view, and the precise edge_id-keyed flow assignment.

◆ max_flow_min_cost_successive_shortest_path()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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().

Parameters
source_idSource node ID.
target_idSink node ID.
capacity_attrName of the numeric edge attribute used as capacity.
weight_attrName of the numeric edge attribute used as cost. The default "weight" refers to the built-in edge-weight property.
Returns
A MinCostMaxFlowResult containing total flow, total cost, the endpoint-keyed convenience flow view, and the precise edge_id-keyed flow assignment.

References nxpp::successive_shortest_path_nonnegative_weights().

◆ maximum_flow()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
source_idSource node ID.
target_idSink node ID.
capacity_attrName of the numeric edge attribute used as capacity.
Returns
A MaximumFlowResult containing the total flow value and the endpoint-keyed convenience flow view plus the precise edge_id-keyed flow assignment.

References nxpp::edmonds_karp_maximum_flow().

◆ minimum_cut()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
source_idSource node ID.
target_idSink node ID.
capacity_attrName of the numeric edge attribute used as capacity.
Returns
A MinimumCutResult containing the cut value, the two partitions, the endpoint-keyed convenience cut-edge view, and the precise cut-edge IDs crossing from reachable to non-reachable nodes.

◆ minimum_spanning_tree() [1/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::minimum_spanning_tree ( ) const

Convenience alias for kruskal_minimum_spanning_tree().

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Returns
A std::vector<std::pair<NodeID, NodeID>> containing the selected spanning-tree edges as (u, v) pairs.

◆ minimum_spanning_tree() [2/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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).

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Parameters
root_idRoot node used to seed Prim's algorithm.
Returns
An ordered std::map<NodeID, NodeID> parent map for the spanning tree.

◆ neighbors()

template<typename NodeID = std::string, typename EdgeWeight = double, bool Directed = false, bool Multi = false, bool Weighted = true, typename OutEdgeSelector = boost::vecS, typename VertexSelector = boost::vecS>
std::vector< NodeID > nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::neighbors ( const NodeID &  u) const
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().

◆ node()

template<typename NodeID = std::string, typename EdgeWeight = double, bool Directed = false, bool Multi = false, bool Weighted = true, typename OutEdgeSelector = boost::vecS, typename VertexSelector = boost::vecS>
NodeAttrBaseProxy nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::node ( const NodeID &  u)
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().

◆ nodes()

template<typename NodeID = std::string, typename EdgeWeight = double, bool Directed = false, bool Multi = false, bool Weighted = true, typename OutEdgeSelector = boost::vecS, typename VertexSelector = boost::vecS>
std::vector< NodeID > nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::nodes ( ) const
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().

◆ num_vertices()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
auto nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::num_vertices ( ) const

Returns the number of vertices currently stored in the graph.

Returns
The current vertex count as an int.

◆ operator[]()

template<typename NodeID = std::string, typename EdgeWeight = double, bool Directed = false, bool Multi = false, bool Weighted = true, typename OutEdgeSelector = boost::vecS, typename VertexSelector = boost::vecS>
NodeProxy nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::operator[] ( const NodeID &  u)
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().

◆ pagerank()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Returns
An indexed_lookup_map<NodeID, double> keyed by public node ID containing one PageRank score per node.

◆ predecessors()

template<typename NodeID = std::string, typename EdgeWeight = double, bool Directed = false, bool Multi = false, bool Weighted = true, typename OutEdgeSelector = boost::vecS, typename VertexSelector = boost::vecS>
std::vector< NodeID > nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::predecessors ( const NodeID &  u) const
inline

Returns predecessor nodes for directed graphs.

For undirected graphs this falls back to the ordinary adjacency view, so the result matches neighbors(u).

◆ prim_minimum_spanning_tree()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
requires (W)
template<bool W>
requires (W)
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.

Template Parameters
WInternal enable/disable gate for weighted graph specializations.
Parameters
root_idRoot node used to seed Prim's algorithm.
Returns
An ordered std::map<NodeID, NodeID> parent map for the spanning tree.

◆ push_relabel_maximum_flow_result()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
source_idSource node ID.
target_idSink node ID.
capacity_attrName of the numeric edge attribute used as capacity.
Returns
A MaximumFlowResult containing the total flow value and the endpoint-keyed convenience flow view plus the precise edge_id-keyed flow assignment.

◆ remove_edge() [1/2]

template<typename NodeID = std::string, typename EdgeWeight = double, bool Directed = false, bool Multi = false, bool Weighted = true, typename OutEdgeSelector = boost::vecS, typename VertexSelector = boost::vecS>
void nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::remove_edge ( const NodeID &  u,
const NodeID &  v 
)
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.

Exceptions
std::runtime_errorIf either node is missing or no such edge exists.

◆ remove_edge() [2/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

◆ remove_node()

template<typename NodeID = std::string, typename EdgeWeight = double, bool Directed = false, bool Multi = false, bool Weighted = true, typename OutEdgeSelector = boost::vecS, typename VertexSelector = boost::vecS>
void nxpp::Graph< NodeID, EdgeWeight, Directed, Multi, Weighted, OutEdgeSelector, VertexSelector >::remove_node ( const NodeID &  u)
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.

Exceptions
std::runtime_errorIf the node is not present.

◆ set_edge_attr()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
template<typename T >
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.

◆ shortest_path() [1/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
source_idSource node ID.
target_idTarget node ID.
Returns
A std::vector<NodeID> describing the path from source to target.
Exceptions
std::runtime_errorIf either node is missing or the target is unreachable.

◆ shortest_path() [2/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
source_idSource node ID.
target_idTarget node ID.
weightCompatibility name for the built-in edge-weight property.
Returns
A std::vector<NodeID> describing the path from source to target.
Exceptions
std::runtime_errorIf either node is missing, the target is unreachable, or the weight name is unsupported.

References nxpp::shortest_path().

◆ shortest_path_length() [1/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
source_idSource node ID.
target_idTarget node ID.
Returns
The path length as a double, measured in edge count.
Exceptions
std::runtime_errorIf either node is missing or the target is unreachable.

References nxpp::shortest_path().

◆ shortest_path_length() [2/2]

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
source_idSource node ID.
target_idTarget node ID.
weightCompatibility name for the built-in edge-weight property.
Returns
The weighted shortest-path length as a double.
Exceptions
std::runtime_errorIf either node is missing, the target is unreachable, or the weight name is unsupported.

References nxpp::shortest_path_length().

◆ successive_shortest_path_nonnegative_weights()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
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.

Parameters
source_idSource node ID.
target_idSink node ID.
capacity_attrName of the numeric edge attribute used as capacity.
weight_attrName of the numeric edge attribute used as cost. The default "weight" refers to the built-in edge-weight property.
Returns
A MinCostMaxFlowResult containing total flow, total cost, the endpoint-keyed convenience flow view, and the precise edge_id-keyed flow assignment.

◆ try_get_edge_attr()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
template<typename T >
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.

◆ try_get_node_attr()

template<typename NodeID , typename EdgeWeight , bool Directed, bool Multi, bool Weighted, typename OutEdgeSelector , typename VertexSelector >
template<typename T >
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.


The documentation for this class was generated from the following files: