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

Function dfs_func

graph/code20.cpp:35–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33// note: line 49 will execute recursively then at the end line 61 will update it then line 51 will make further updations
34
35void dfs_func(vector<int> vec[], int source, vector<bool> &visited, vector<int> &disc, vector<int> &low, int &time, int parent)
36{
37 visited[source] = true;
38 disc[source] = low[source] = time;
39
40 time++;
41
42 for (int i = 0; i < vec[source].size(); i++)
43 {
44 int adjacent = vec[source][i];
45 if (visited[adjacent] == false)
46 {
47
48 // calling recursion function
49 dfs_func(vec, adjacent, visited, disc, low, time, source);
50 // after we make low value less for adjacent we call this fucntion so that this can further update it
51 low[source] = min(low[source], low[adjacent]);
52
53 if (low[adjacent] > disc[source])
54 {
55 cout << source << " " << adjacent << endl;
56 }
57 }
58 // when we get visited adjacent we call min function to make low value less...
59 else if (visited[adjacent] == true && adjacent != parent)
60 {
61 low[source] = min(low[source], disc[adjacent]);
62 }
63 }
64}
65
66void bridges(vector<int> vec[], int v)
67{

Callers 1

bridgesFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected