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

Function bfs

CPP/graphseries.cpp:52–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52void bfs(int node, vector<int> &vis, vector<int> arr[], vector<int> &ans)
53{
54 queue<int> q;
55 q.push(node);
56 vis[node] = 1;
57 while (!q.empty())
58 {
59 int f = q.front();
60 q.pop();
61 ans.push_back(f);
62 for (auto i : arr[f])
63 {
64 if (!vis[i])
65 {
66 vis[i] = 1;
67 q.push(i);
68 }
69 }
70 }
71}
72
73void dfs(int node, vector<int> &vis, vector<int> arr[], vector<int> &ans)
74{

Callers

nothing calls this directly

Calls 3

push_backMethod · 0.80
pushMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected