MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / kosaraju

Function kosaraju

graph/code18.cpp:71–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71void kosaraju(vector<int> vec[], int v, vector<int> transpose[])
72{
73 vector<bool> visited(v, false);
74 int source = 0;
75 stack<int> st;
76 // finding topo sort first
77 topo_sort(vec, source, visited, st);
78
79 // finding transpose
80 find_transpose(vec, v, transpose);
81
82 // final step of printing connected components .. we wll do it via dfs
83 for (int i = 0; i < visited.size(); i++)
84 {
85 // making visited vector again false as it is used in topo_sort and it is all true
86 visited[i] = false;
87 }
88 cout << "Printing connected components: " << endl;
89 for (int i = 0; i < visited.size(); i++)
90 {
91 if (visited[i] == false)
92 {
93 dfs(transpose, i, visited);
94 cout << endl;
95 }
96 }
97}
98
99int main()
100{

Callers 1

mainFunction · 0.70

Calls 4

find_transposeFunction · 0.85
topo_sortFunction · 0.70
dfsFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected