Advertisement
istinishat

Odd cycle detect in a graph

Apr 19th, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //sudo code
  2. // vertex are colored with black & white colors
  3. //http://codeforces.com/contest/557/submission/11870749
  4. for(int i=0;i<n;i++)
  5.     {
  6.         if(!vis[i])
  7.             dfs(i,0);
  8.         for(auto u:v[i])
  9.             if(color[u]==color[i]){
  10.                 return "found odd cycle";
  11.             }
  12.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement