![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Functions | |
| int | sortLinks (const int *node1, const int *node2, int n_links, int n_nodes, std::vector< int > &sorted_links, const int *divert_link=nullptr) |
| Sort links in topological (upstream→downstream) order. | |
| int openswmm::toposort::sortLinks | ( | const int * | node1, |
| const int * | node2, | ||
| int | n_links, | ||
| int | n_nodes, | ||
| std::vector< int > & | sorted_links, | ||
| const int * | divert_link = nullptr ) |
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.
| node1 | [in] Upstream node index per link. |
| node2 | [in] Downstream node index per link. |
| n_links | Number of links. |
| n_nodes | Number of nodes. |
| sorted_links | [out] Topologically sorted link indices. |
| divert_link | [in] Optional, per node: the index of that node's DIVERSION link when the node is a 2-outlet divider, else -1. Legacy adjustAdjList (toposort.c:191-217) swaps a divider's two outgoing links so the NON-diversion one is routed first — divider_getOutflow gives the diversion link qIn - Node.outflow, i.e. only what the other link left behind, so the wrong order sends the node's whole inflow down BOTH links. Pass nullptr to skip the adjustment. |