You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/graph/strongly-connected-components.md
+36-42Lines changed: 36 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -72,72 +72,66 @@ The runtime complexity of the algorithm is $O(n + m)$, because depth first searc
72
72
Finally, it is appropriate to mention [topological sort](topological-sort.md) here. In step 2, the algorithm finds strongly connected components in decreasing order of their exit times. Thus, it finds components - vertices of the condensation graph - in an order corresponding to a topological sort of the condensation graph.
73
73
74
74
## Implementation
75
-
```cpp
76
-
vector<vector<int>> adj, adj_rev; // adjacency lists of G and G^T
77
-
vector<bool> visited; // keeps track of which nodes are already visited
78
-
vector<int> order; // sorted list of G's vertices by exit time
79
-
vector<int> component; // stores one strongly connected component at a time
80
-
81
-
voiddfs1(int v) {
75
+
```{.cpp file=strongly_connected_components}
76
+
vector<bool> visited; // keeps track of which nodes are already visited
77
+
78
+
// runs depth first search starting at vertex v.
79
+
// each visited vertex is appended to the output vector when dfs leaves it.
0 commit comments