Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <strongly_connected_components.h>
Public Member Functions | |
void | FindStronglyConnectedComponents (const NodeIndex num_nodes, const Graph &graph, SccOutput *components) |
bool | NodeIsInCurrentDfsPath (NodeIndex node) const |
This implementation is slightly different than a classical iterative version of Tarjan's strongly connected components algorithm. But basically it is still an iterative DFS. We use a class so memory can be reused if one needs to compute many SCC in a row. It also allows more complex behavior in the Graph or SccOutput class that might inspect the current state of the algorithm.
Definition at line 105 of file strongly_connected_components.h.
|
inline |
Reset the class fields.
Caching the pointer to this vector.data() avoid re-fetching it and help.
Optimization. This will always be equal to scc_start_index_.back() except when scc_stack_ is empty, in which case its value does not matter.
Loop over all the nodes not yet settled and start a DFS from each of them.
We continue the dfs from this node and set its 1-based index.
Enqueue all its adjacent nodes.
Update the start of this strongly connected component.
We found a strongly connected component.
Definition at line 107 of file strongly_connected_components.h.
|
inline |
Advanced usage. This can be used in either the Graph or SccOutput template class to query the current state of the algorithm. It allows to build more complex variant based on the core DFS algo.
Definition at line 181 of file strongly_connected_components.h.