千年共枕眠:关于图的问题,懂的来帮帮忙

来源:百度文库 编辑:高校问答 时间:2024/05/03 05:06:56
DFS和BFS的区别?我看它们的定义,觉得它们差不多的啊!!

是差不多.
但在找结(顶)点时有所不同.
DFS是涉及深度寻找时好.
BFS是涉及广度寻找时优越.

For BFS in directed graphs(有向图), each edge of the graph either connects two vertices(两个顶点) at the same level goes down exactly one level(本层和下一层), or goes up any number of levels(向上任意层).

For DFS, each edge either connects an ancestor to a descendant, a descendant to an ancestor, or one node to a node in a previously visited subtree. It is not possible to get "forward edges" connecting a node to a subtree visited later than that node.

http://www.ics.uci.edu/~eppstein/161/960215.html