filmov
tv
How to modify BFS algorithm to output the shortest path?
Показать описание
A short and direct tutorial to show the easy way to find the shortest path by using the concept of BFS Algorithm. BFS Shortest Path.
Tips, write a wrapper to store 2 data else you have to insert twice.
Note: The path of 1 in the beginning is simply "1"
vertexNow:
1 (vertex) - "1" (nowPath)
Queue
| 2 nowPath + "-" + "2"
| 3 nowPath + "-" + "3"
| 4 nowPath + "-" + "4"
| 7 nowPath + "-" + "7"
#graph
#adjacent
#AdjacentList
#vertex
#vertices
#edge #bfs #shortestPath
#shortest-path
#shortest_path
Tips, write a wrapper to store 2 data else you have to insert twice.
Note: The path of 1 in the beginning is simply "1"
vertexNow:
1 (vertex) - "1" (nowPath)
Queue
| 2 nowPath + "-" + "2"
| 3 nowPath + "-" + "3"
| 4 nowPath + "-" + "4"
| 7 nowPath + "-" + "7"
#graph
#adjacent
#AdjacentList
#vertex
#vertices
#edge #bfs #shortestPath
#shortest-path
#shortest_path