Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1.  
  2. color = [0] * n
  3. flag = True
  4.  
  5. def dfs(v, c):
  6. color[v] = c
  7. if c == 1:
  8. c = 2
  9. else:
  10. c = 1
  11. for u in range(n):
  12. if a[v][u] == 1:
  13. if color[u] != 0 and color!=c:
  14. flag = False
  15. if color[u] == 0:
  16. dfs(u, c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement