For some graphs, DFS and BFS search algorithms process nodes in the exact same order provided that they both start at the same node. Two examples are graphs that are paths and graphs that are star-shaped (trees of depth $1$ with an arbitrary number of children). Is there some way for categorizing graphs that satisfy this property?
Tell me more
×
Computer Science Stack Exchange is a question and answer site for
students, researchers and practitioners of computer science. It's 100% free, no registration required.
|
|
Assume our BFS and dfs has a rule to start from specific node and in each two-way they first visit node with lowest degree:
start from left most black node, then (BFS and DFS) are visit left most red node, then they will visit next black node, and so on, for make it more general, you could add some paths in between triangles, or add star after finishing triangles ... |
|||||||||||||
|
