Skip to main content
added 25 characters in body
Source Link
Lajos Arpad
  • 81.5k
  • 42
  • 124
  • 237

enter image description hereIllustration of an example graph
I

I am studying Depth First Search (DFS) on undirected graphs and I am confused about discovery order.

I have attached a figure of an undirected graph with DFS discovery (d) and finishing (f) times marked on each vertex.

In my traversal, vertex d directly discovers vertex e (there is an edge between them, and e is still unvisited when DFS is at d).

However, I have seen explanations suggesting that DFS must backtrack to an ancestor (like a) before discovering e, even though d is connected to e.

My questions are:

  1. Is my DFS traversal and timing valid?

  2. Can d directly discover e in DFS, or does this depend on adjacency list order?

  3. Is there any DFS rule that forbids discovering e from d if an edge exists?

I want to be sure I am applying DFS rules correctly.

enter image description here
I am studying Depth First Search (DFS) on undirected graphs and I am confused about discovery order.

I have attached a figure of an undirected graph with DFS discovery (d) and finishing (f) times marked on each vertex.

In my traversal, vertex d directly discovers vertex e (there is an edge between them, and e is still unvisited when DFS is at d).

However, I have seen explanations suggesting that DFS must backtrack to an ancestor (like a) before discovering e, even though d is connected to e.

My questions are:

  1. Is my DFS traversal and timing valid?

  2. Can d directly discover e in DFS, or does this depend on adjacency list order?

  3. Is there any DFS rule that forbids discovering e from d if an edge exists?

I want to be sure I am applying DFS rules correctly.

Illustration of an example graph

I am studying Depth First Search (DFS) on undirected graphs and I am confused about discovery order.

I have attached a figure of an undirected graph with DFS discovery (d) and finishing (f) times marked on each vertex.

In my traversal, vertex d directly discovers vertex e (there is an edge between them, and e is still unvisited when DFS is at d).

However, I have seen explanations suggesting that DFS must backtrack to an ancestor (like a) before discovering e, even though d is connected to e.

My questions are:

  1. Is my DFS traversal and timing valid?

  2. Can d directly discover e in DFS, or does this depend on adjacency list order?

  3. Is there any DFS rule that forbids discovering e from d if an edge exists?

I want to be sure I am applying DFS rules correctly.

Source Link

DFS Algorithm for undirected graph

enter image description here
I am studying Depth First Search (DFS) on undirected graphs and I am confused about discovery order.

I have attached a figure of an undirected graph with DFS discovery (d) and finishing (f) times marked on each vertex.

In my traversal, vertex d directly discovers vertex e (there is an edge between them, and e is still unvisited when DFS is at d).

However, I have seen explanations suggesting that DFS must backtrack to an ancestor (like a) before discovering e, even though d is connected to e.

My questions are:

  1. Is my DFS traversal and timing valid?

  2. Can d directly discover e in DFS, or does this depend on adjacency list order?

  3. Is there any DFS rule that forbids discovering e from d if an edge exists?

I want to be sure I am applying DFS rules correctly.

created from staging ground