DFS(v): Depth-First Search mark v while there is an unmarked node w adjacent to node v DFS(w) end
connected components O(m+n)
BFS(v): Breadth-First Search mark v Q=Qv while Q is nonempty do