Skip to main content Accessibility help
×
Hostname: page-component-848d4c4894-xfwgj Total loading time: 0 Render date: 2024-06-27T13:53:42.128Z Has data issue: false hasContentIssue false

3 - Depth-First Search

Published online by Cambridge University Press:  05 June 2012

Guy Even
Affiliation:
Tel-Aviv University
Get access

Summary

DFS of Undirected Graphs

The depth-first search (DFS) technique is a method of scanning a finite, undirected graph. Since the publication of the papers of Hopcroft and Tarjan [4, 6], DFS has been widely recognized as a powerful technique for solving various graph problems. However, the algorithm has been known since the nineteenth century as a technique for threading mazes. See, for example, Lucas' report of Trémaux's work [5]. Another algorithm, which was suggested later by Tarry [7], is just as good for threading mazes, and in fact, DFS is a special case of it. But the additional structure of DFS is what makes the technique so useful.

Trémaux's Algorithm

Assume one is given a finite, connected graph G(V,E), which we will also refer to as the maze. Starting in one of the vertices, one wants to “walk” along the edges, from vertex to vertex, visit all vertices, and halt. We seek an algorithm that will guarantee that the whole graph will be scanned without wandering too long in the maze, and that the procedure will allow one to recognize when the task is done. However, before one starts walking in the maze, one does not know anything about its structure, and therefore, no preplanning is possible. So, decisions about where to go next must be made one by one as one goes along.

We will use “markers,” which will be placed in the maze to help one to recognize that one has returned to a place visited earlier and to make later decisions on where to go next.

Type
Chapter
Information
Graph Algorithms , pp. 46 - 64
Publisher: Cambridge University Press
Print publication year: 2011

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

References

[1] J.E., Hopcroft, A.V., Aho, and J.D., Ullman. Data Structures and Algorithms. Addison-Wesley, 1983.Google Scholar
[2] A.S., Fraenkel. “Economic traversal of labyrinths.” Math. Mag., 43(1):125–130, 1970.Google Scholar
[3] A.S., Fraenkel. “Economic traversal of labyrinths (correction).” Math. Mag., 44, 1971.Google Scholar
[4] J., Hopcroft and R., Tarjan. “Algorithm 447: Efficient algorithms for graph manipulation.” Comm. of the ACM, 16:372–378, 1973.Google Scholar
[5] E., Lucas. Récreations Mathématiques. Paris, 1882.Google Scholar
[6] R., Tarjan. “Depth-first search and linear graph algorithms.” SIAM J. on Computing, 1:146–160, 1972.Google Scholar
[7] G., Tarry. “Le problème des labyrinthes.” Nouvelles Annales de Math., 14:187, 1895.Google Scholar

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Depth-First Search
  • Shimon Even
  • Edited by Guy Even, Tel-Aviv University
  • Book: Graph Algorithms
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139015165.006
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Depth-First Search
  • Shimon Even
  • Edited by Guy Even, Tel-Aviv University
  • Book: Graph Algorithms
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139015165.006
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Depth-First Search
  • Shimon Even
  • Edited by Guy Even, Tel-Aviv University
  • Book: Graph Algorithms
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139015165.006
Available formats
×