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

Function bipertiteBFS

CPP/graphseries.cpp:87–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87bool bipertiteBFS(int n, vector<int> &color, vector<int> arr[])
88{
89 queue<int> q;
90 q.push(n);
91 color[n] = 1;
92 while (!q.empty())
93 {
94 int front = q.front();
95 q.pop();
96 for (auto i : arr[n])
97 {
98 if (color[i] == -1)
99 {
100 color[i] = 1 - color[n];
101 q.push(i);
102 }
103 else
104 {
105 if (color[i] == color[n])
106 return false;
107 }
108 }
109 }
110
111 return true;
112}
113
114bool bipertiteDFS(int n, vector<int> &color, vector<int> arr[])
115{

Callers

nothing calls this directly

Calls 2

pushMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected