您的位置:首页 > 编程语言 > Go语言

algorithm@ find the shortest path in a graph using BFS

2016-03-16 03:34 741 查看
[b]Finding Shortest Paths By BFS[/b]
􀁺 The BFS code we have seen
  􀁻 find outs if there exist a path from a vertex s to a vertex v
  􀁻 prints the vertices of a graph (connected/strongly connected).
􀁺 What if we want to find
  􀁻 the shortest path from s to a vertex v (or to every other vertex)?
  􀁻 the length of the shortest path from s to a vertex v?
􀁺 In addition to array flag[ ], use an array named prev[ ], one element per vertex.
  􀁻 prev[w] = v means that vertex w was visited right after v

















































内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: