|
|
| Network ()=default |
| | Construct a new empty Network object.
|
|
auto | nodes () const noexcept |
| | Get the nodes as a view of (id, pointer to const node) pairs.
|
|
auto | nodes () noexcept |
| | Get the nodes as a view of (id, pointer to node) pairs.
|
|
auto | edges () const noexcept |
| | Get the edges as a view of (id, pointer to const edge) pairs.
|
|
auto | edges () noexcept |
| | Get the edges as a view of (id, pointer to edge) pairs.
|
|
auto | nNodes () const noexcept |
| | Get the number of nodes.
|
|
auto | nEdges () const noexcept |
| | Get the number of edges.
|
template<typename TNode = node_t, typename... TArgs>
requires (std::is_base_of_v<node_t, TNode> && std::constructible_from<TNode, TArgs...>) |
| void | addNode (TArgs &&... args) |
template<typename TNode = node_t>
requires (std::is_base_of_v<node_t, TNode>) |
| void | addNDefaultNodes (std::size_t const n) |
template<typename TEdge = edge_t, typename TNode = node_t, typename... TArgs>
requires (std::is_base_of_v<edge_t, TEdge> && std::is_base_of_v<node_t, TNode> && std::constructible_from<TEdge, Id, std::pair
<Node*, Node*>, TArgs...>) |
| TEdge & | addEdge (Id const edgeId, std::pair< Id, Id > const nodeIds, TArgs &&... args) |
| | Add an edge between two nodes, creating the missing ones.
|
| virtual void | setEdgeWeight (std::string_view const strv_weight, std::optional< double > const threshold=std::nullopt)=0 |
| const auto & | node (Id const nodeId) const |
| | Get a node by id.
|
| auto & | node (Id const nodeId) |
| | Get a node by id.
|
| const auto & | edge (Id const edgeId) const |
| | Get an edge by id.
|
| auto & | edge (Id const edgeId) |
| | Get an edge by id.
|
|
edge_t & | edge (Id const source, Id const target) const |
template<typename TNode>
requires (std::is_base_of_v<node_t, TNode>) |
| auto & | node (Id const nodeId) |
| | Get a node by id and cast it to a derived type.
|
template<typename TEdge>
requires (std::is_base_of_v<edge_t, TEdge>) |
| auto & | edge (Id const edgeId) |
| | Get an edge by id and cast it to a derived type.
|
| PathCollection | allPathsTo (Id const targetId) const |
| | Perform a global Dijkstra search to a target node from all other nodes in the graph.
|
| PathCollection | shortestPath (Id const sourceId, Id const targetId) const |
| | Find the shortest path between two nodes using Dijkstra's algorithm.
|
|
void | computeBetweennessCentralities () |
| | Compute node weighted betweenness centralities using Brandes' algorithm.
|
|
void | computeEdgeBetweennessCentralities () |
| | Compute edge weighted betweenness centralities using Brandes' algorithm.
|
| void | computeEdgeKBetweennessCentralities (std::size_t const K) |
| | Compute edge betweenness centralities using Yen's K-shortest paths.
|
template<typename node_t, typename edge_t>
requires (std::is_base_of_v<
Node, node_t> && std::is_base_of_v<
Edge, edge_t>)
| void dsf::Network< node_t, edge_t >::computeEdgeKBetweennessCentralities |
( |
std::size_t const | K | ) |
|
Compute edge betweenness centralities using Yen's K-shortest paths.
For every ordered source–target pair (s, t) with s ≠ t the method finds up to K loopless shortest paths using Yen's algorithm. Each edge e that appears in at least one of those paths receives an increment equal to the number of those K paths that traverse it. After all pairs are processed the raw counts are normalised by (N−1)·(N−2), the number of ordered pairs in a directed graph of N nodes (same denominator used by the standard Brandes formulation).
The computation is parallelised over source nodes with Intel TBB: each thread maintains its own accumulator map, which are merged sequentially once all threads finish.
- Parameters
-
| K | Maximum number of shortest paths per (s, t) pair. K = 1 reproduces single-shortest-path betweenness. |
template<typename node_t, typename edge_t>
template<typename TNode, typename... TArgs>
requires (std::is_base_of_v<node_t, TNode> && std::constructible_from<TNode, node_t const&, TArgs...>)
| TNode & dsf::Network< node_t, edge_t >::m_replaceNode |
( |
std::unique_ptr< node_t > & | pNode, |
|
|
TArgs &&... | args ) |
|
inlineprotected |
Replace a node with a new object of type TNode, built from the old one.
The new node keeps the old node's edges, whose source/target node pointers are re-linked to it. Any other reference to the old node dangles. Safe to call concurrently for different nodes: for an edge u -> v, u only writes the edge's source node and v only its target node.
- Parameters
-
| pNode | The network's owning pointer to the node to replace |
| args | Extra arguments forwarded to TNode's constructor, after the old node |
- Returns
- TNode& A reference to the new node