Skip to main content

Timeline for Depth-first search in Python

Current License: CC BY-SA 3.0

9 events
when toggle format what by license comment
Sep 1, 2017 at 8:53 comment added BBSysDyn You are using set to keep track of visit order but set() is not guaranteed to give correct order. visited should be a list.
S Feb 20, 2015 at 12:14 history suggested CommunityBot CC BY-SA 3.0
bfs typo; changed to complete term
Feb 20, 2015 at 11:50 review Suggested edits
S Feb 20, 2015 at 12:14
Feb 5, 2015 at 3:48 vote accept meto
Jan 26, 2015 at 12:57 comment added sapi @JanneKarila Good point; I was picturing a top-down tree (where that won't occur for a DFS), but of course that's a very specific case.
Jan 26, 2015 at 11:05 comment added Janne Karila @sapi A node would be pushed multiple times to stack if it can be reached from multiple nodes that happen to be visited before it.
Jan 26, 2015 at 10:02 comment added f.rodrigues Makes sense. Seems redundant. The code ain't mine tho, the link provide may have some info on that.
Jan 26, 2015 at 9:47 comment added sapi Unless I'm missing something, if you only ever add unvisited nodes to the stack, you shouldn't need the if vertex not in visited check (presuming a node cannot have two links to the same child). Which you want would depend on whether set subtraction or contains is faster (I would guess the latter).
Jan 26, 2015 at 4:53 history answered f.rodrigues CC BY-SA 3.0