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

Function bfs

graph/code4.cpp:13–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13void bfs(vector<int> vec[], int v, int source, vector<bool> &visited)
14{
15 queue<int> q;
16 q.push(source);
17 visited[source] = true;
18
19 while (q.empty() == false)
20 {
21 int curr = q.front();
22 q.pop();
23
24 cout << curr << " ";
25 for (int i = 0; i < vec[curr].size(); i++)
26 {
27 int adjacent = vec[curr][i];
28 if (visited[adjacent] == false)
29 {
30 q.push(adjacent);
31 visited[adjacent] = true;
32 }
33 }
34 }
35}
36
37void bfs_recursive(vector<int> vec[], int v)
38{

Callers 2

bfs_recursiveFunction · 0.70
findLaddersMethod · 0.50

Calls 3

pushMethod · 0.45
popMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected