LOGBOOK

HELP

Quiz Entry - updated: 2026.11.27

Run DFS from A on the graph with edges A–B, A–C, A–D, A–E, B–C, C–D, C–E, taking each vertex's edges in alphabetical order of the far vertex. Which edges become discovery edges, and which back edges?

Discovery edges: A–B, B–C, C–D, C–E, with the vertices visited in the order A, B, C, D, E. Back edges: C–A, D–A and E–A.

The five-vertex graph after DFS from A: discovery edges A-B, B-C, C-D, C-E and back edges from C, D and E to A, with the visiting order 1 to 5

* Every back edge points from a vertex to an ancestor on its path from A. *

The trace, call by call:

  1. DFS(A): the first edge, A–B, leads to the unexplored B, so A–B becomes a discovery edge.
  2. DFS(B): A–B is already labelled and skipped; B–C leads to the unexplored C: discovery edge.
  3. DFS(C): C–A leads to A, already visited: back edge. C–B is labelled. C–D leads to D: discovery edge.
  4. DFS(D): D–A leads to A: back edge. D–C is labelled. D has no edges left, so the call returns to C.
  5. DFS(C) continues: C–E leads to E: discovery edge. DFS(E): E–A is a back edge, E–C is labelled, return.
  6. Back in B and then in A, the remaining edges A–C, A–D and A–E are all labelled already, and the search ends.

The counts check out: 4 discovery edges for 5 vertices, exactly what a spanning tree needs, plus 3 back edges, 7 edges in all. Another start vertex or another order of the incident edges would give another tree, which is why the order is fixed in the question.

Go deeper:

  • tool VisuAlgo: graph traversal — draw a graph or pick an example and step through DFS and BFS; its graphs are directed, so draw an undirected edge as two opposite edges.

From Quiz: ADS / Graph Traversals: Depth-First and Breadth-First Search | Updated: Nov 27, 2026