Skip to content

Instantly share code, notes, and snippets.

@texel
Created May 13, 2010 20:52
Show Gist options
  • Save texel/400442 to your computer and use it in GitHub Desktop.
Save texel/400442 to your computer and use it in GitHub Desktop.
def dfs_order(vertex)
vertex.mark!
vertex.set_discover_time(@time += 1)
vertex.edges.each do |edge_vertex|
unless edge_vertex.visited?
edge_vertex.parent = vertex
dfs_order(edge_vertex)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment