【发布时间】:2016-10-03 17:54:03
【问题描述】:
有向图和无向图上的 bfs 在实现上有何不同。
我在网上找到了以下伪代码。我对无向图很好。但不知道如何为有向图实现它。
frontier = new Queue()
mark root visited (set root.distance = 0)
frontier.push(root)
while frontier not empty {
Vertex v = frontier.pop()
for each successor v' of v {
if v' unvisited {
frontier.push(v')
mark v' visited (v'.distance = v.distance + 1)
}
}
}
【问题讨论】:
-
还是一样的。
-
啊已经知道了.. 感谢您的回复
-
好吧..感谢那个为我的问题投票的人
标签: breadth-first-search directed-graph