Depth-First Search of a Graph

I am a bit confused with this example . Normally the depth- first search of a graph is done in alphabetical/ increasing order . (Is it possible for vertex M to be visited third? starting from vertex B ) . Can someone please explain this to me :

enter image description here

Upvotes: 0

Views: 74

Answers (1)

Codor
Codor

Reputation: 17595

Yes, it is possible to visit vertex M as third vertex when starting from B, namely starting at B, then visiting its neighbour A and then visiting A's neighbour M. Note that for depth-first-search, as presented here, there is usually no rule in which order the neighbours of a vertex are visited, such that usually the visiting sequence of the vertices is not uniquely determined.

Upvotes: 1

Related Questions