Guest User

Untitled

a guest
Nov 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. Situation 1. G has no cycle
  2. It seems we need to do BFS, traverse the graph from the bottom, let each edge point to the leaf vertex, since it's a graph without any cycles, so each vertex will have at most one edge point to it. And BFS takes O(V+E) time.
  3.  
  4. Situation 2. G has at most 1 cycle
  5. If there is a cycle how could we choose the direction of 2 edges that point to the same vertex?
Add Comment
Please, Sign In to add comment