Java Reference
In-Depth Information
12 vertices are searched in this DFS order:
Chicago Seattle San Francisco Los Angeles Denver
Kansas City New York Boston Atlanta Miami Houston Dallas
parent of Seattle is Chicago
parent of San Francisco is Seattle
parent of Los Angeles is San Francisco
parent of Denver is Los Angeles
parent of Kansas City is Denver
parent of Boston is New York
parent of New York is Kansas City
parent of Atlanta is New York
parent of Miami is Atlanta
parent of Dallas is Houston
parent of Houston is Miami
F IGURE 28.13
A DFS search starts from Chicago.
28.7.3 Applications of the DFS
The depth-first search can be used to solve many problems, such as the following:
Detecting whether a graph is connected. Search the graph starting from any vertex.
If the number of vertices searched is the same as the number of vertices in the graph,
 
 
Search WWH ::




Custom Search