http://www.perlmonks.org?node_id=868266


in reply to Short Circuiting DFS Graph Traversal

I am not sure I correctly understod the problem, but it seems Dijkstra's algorithm with all edges set to one should work.