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

Function dist_minm

graph/code19.cpp:32–70  ·  view source on GitHub ↗

note: line 48 will execute recursively then at the end line 60 will update it then line 50 will make further updations

Source from the content-addressed store, hash-verified

30
31// note: line 48 will execute recursively then at the end line 60 will update it then line 50 will make further updations
32void dist_minm(vector<int> vec[], int source, vector<bool> &visited, vector<int> &disc, vector<int> &low, int &time, int parent,
33 vector<bool> &isap)
34{
35 visited[source] = true;
36 disc[source] = low[source] = time;
37 time++;
38
39 int children = 0;
40
41 for (int i = 0; i < vec[source].size(); i++)
42 {
43 int adjacent = vec[source][i];
44 if (visited[adjacent] == false)
45 {
46 children++;
47 // calling recursion function
48 dist_minm(vec, adjacent, visited, disc, low, time, source, isap);
49 // after we make low value less for adjacent we call this fucntion so that this can further update it
50 low[source] = min(low[source], low[adjacent]);
51
52 if (low[adjacent] >= disc[source] && parent != -1)
53 {
54 isap[source] = true;
55 }
56 }
57 // when we get visited adjacent we call min function to make low value less...
58 else if (visited[adjacent] == true && adjacent != parent)
59 {
60 low[source] = min(disc[adjacent], low[source]);
61 }
62 }
63 // we separately check for root node as even if nodes ends at node there is no prior node from which we can say that it made two parts
64 // so we check for children of this node and by children we means that children which are not reachable from each other directly .. they
65 // firstly have to go through root itself..
66 if (parent == -1 && children > 1)
67 {
68 isap[source] = true;
69 }
70}
71
72void arti_point(vector<int> vec[], int v)
73{

Callers 1

arti_pointFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected