Does order of exploration in DFS affect edge classification

Viewed 550

I'm implementing DFS and edge classification for college (based on the code provided in this paper: https://courses.csail.mit.edu/6.006/fall11/rec/rec14.pdf).

I've used this graph as a test:enter image description here

The letters in italic are simply the vertices' names, while the numbers inside the vertices are discovery and finalization time, respectively. Edges are classified as Back, Forward or Cross; all else are tree edges.

As you can see, this graph was visited in the following order: first s, then its neighbors (following DFS); when there were no more accessible neighbors, visitation began on t.

In order to test our algorithm, the teacher will provide a text file with each edge as a line. When performing the DFS, I simply follow the order of appearance in the file for each vertex; in this case, that would be first s and then v, not t. This in turn gives a different edge classification: t to v is considered a cross edge, t to u a back one and u to t a tree one.

Is this behavior normal? Does the order of exploration affect the final edge classification? If so, are both classifications, mine and the example's, correct? If not, is there any way I can know which vertex to explore first?

1 Answers
Related