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

Function bipertiteDFS

CPP/graphseries.cpp:114–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114bool bipertiteDFS(int n, vector<int> &color, vector<int> arr[])
115{
116 if (color[n] == -1)
117 color[n] = 1;
118 for (auto i : arr[n])
119 {
120 if (color[i] == -1)
121 {
122 color[i] = 1 - color[n];
123 if (!bipertiteDFS(i, color, arr))
124 return false;
125 }
126 else
127 {
128 if (color[i] == color[n])
129 return false;
130 }
131 }
132 return true;
133}
134
135bool cycleDirectedDFS(int n, vector<int> &vis, vector<int> &dfsvis, vector<int> arr[])
136{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected