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

Function dfs

graph/code10.cpp:15–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13}
14
15bool dfs(vector<int> vec[], vector<bool> &visited, vector<bool> &recst, int source)
16{
17 visited[source] = true;
18 recst[source] = true;
19 for (int i = 0; i < vec[source].size(); i++)
20 {
21 int adjacent = vec[source][i];
22 if (visited[adjacent] == false)
23 {
24 if (dfs(vec, visited, recst, adjacent) == true)
25 {
26 return true;
27 }
28 }
29 else if (visited[adjacent] == true && recst[adjacent] == true)
30 {
31 return true;
32 }
33 }
34 recst[source] = false;
35 return false;
36}
37
38bool dfs_rec(vector<int> vec[], int v)
39{

Callers 1

dfs_recFunction · 0.70

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected