DFS

Definition

First, choosing a beginning point V and mark it as an already visited one. Then, starting from the V to search for each point W closed to V.  If W has not been visited, then taking W as the new beginning  to loop the depth first traversal. Until all the reachable vertices from the beginning V have been visited, the loop ends.

  If there is still no reachable vertices in this graph, just choosing another vertex which has not been accessed as a new beginning point to repeat the above process until all vertices in the graph have been visited.

 

Status

Depth first search is a classical algorithm in graph theory. Using DFS can generate the corresponding target topology diagram sorting table which can easily solve many problems related to graph theory, such as the maximum path problem and so on.

 

Algorithm

063906_YTGH_2660780.png

063916_gKrQ_2660780.png

 

Example

發佈了47 篇原創文章 · 獲贊 4 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章