mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Add doctest to dijkstra-algorithm
This commit is contained in:
parent
8679c63752
commit
b511783731
@ -56,9 +56,9 @@ def dijkstra(graph, v, src):
|
||||
|
||||
Example:
|
||||
>>> graph = [[0.0, 2.0, float('inf'), 1.0],
|
||||
[2.0, 0.0, 4.0, float('inf')],
|
||||
[float('inf'), 4.0, 0.0, 3.0],
|
||||
[1.0, float('inf'), 3.0, 0.0]]
|
||||
... [2.0, 0.0, 4.0, float('inf')],
|
||||
... [float('inf'), 4.0, 0.0, 3.0],
|
||||
... [1.0, float('inf'), 3.0, 0.0]]
|
||||
>>> dijkstra(graph, 4, 0)
|
||||
Vertex Distance
|
||||
0 0
|
||||
@ -102,4 +102,4 @@ if __name__ == "__main__":
|
||||
graph[src][dst] = weight
|
||||
|
||||
gsrc = int(input("\nEnter shortest path source:").strip())
|
||||
dijkstra(graph, V, gsrc)
|
||||
dijkstra(graph, V, gsrc)
|
||||
|
Loading…
Reference in New Issue
Block a user