World's most popular travel blog for travel bloggers.

[Solved]: How to perform alphabetically ordered DFS?

, , No Comments
Problem Detail: 

I've been working on this graph and just completely botching it. I mean to say that my solution may be the worst possible other than if a monkey had thrown darts at the graph to decide the next path. Anyhow, I'm lost and really trying to get a grasp of where my conclusion and the proper conclusion diverged dramatically.

I wanted to perform a DFS, show discovery/finish times, the DF forest, and edge classifications. I assumed that: 1) The vertices are listed in alphabetical order in each adjacency list. 2) The vertices are taken in the alphabetical order in the main loop of the DFS algorithm.

Should I be treating this as a directed acyclic graph?

Asked By : stackuser

Answered By : Pål GD

$L$ has an edge to $K$, other than that, the DFS forest you've drawn is correct. And since $K$ would not be expanded before $L$, there should be an edge $LK$ in the BFS forest.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/12728

0 comments:

Post a Comment

Let us know your responses and feedback