OpenSWMM Engine  6.0.0-alpha.3
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.3)
Loading...
Searching...
No Matches
openswmm::toposort Namespace Reference

Functions

int sortLinks (const int *node1, const int *node2, int n_links, int n_nodes, std::vector< int > &sorted_links)
 Sort links in topological (upstream→downstream) order.
 

Function Documentation

◆ sortLinks()

int openswmm::toposort::sortLinks ( const int * node1,
const int * node2,
int n_links,
int n_nodes,
std::vector< int > & sorted_links )

Sort links in topological (upstream→downstream) order.

Uses Kahn's algorithm with CSR adjacency from node1/node2. Returns the number of sorted links. If < n_links, a cycle exists.

Parameters
node1[in] Upstream node index per link.
node2[in] Downstream node index per link.
n_linksNumber of links.
n_nodesNumber of nodes.
sorted_links[out] Topologically sorted link indices.
Returns
Number of sorted links (< n_links indicates cycle).
Here is the caller graph for this function: