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

Example

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券