mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-18 17:20:16 +00:00
changing pytest
This commit is contained in:
parent
e1eb17e83e
commit
8be7753175
|
@ -33,17 +33,16 @@ def floyd_warshall(graph, v):
|
|||
updated to the next vertex[i][k].
|
||||
|
||||
|
||||
>>> num_vertices = 3
|
||||
>>> graph = [
|
||||
... [float('inf'), float('inf'), float('inf')],
|
||||
... [float('inf'), float('inf'), float('inf')],
|
||||
... [float('inf'), float('inf'), float('inf')]
|
||||
... [0, 3, float('inf')],
|
||||
... [2, 0, float('inf')],
|
||||
... [float('inf'), 7, 0]
|
||||
... ]
|
||||
|
||||
>>> expected = [
|
||||
... [0, 2, float('inf')],
|
||||
... [1, 0, float('inf')],
|
||||
... [float('inf'), float('inf'), 0]
|
||||
... [0, 3, float('inf')],
|
||||
... [2, 0, float('inf')],
|
||||
... [9, 7, 0]
|
||||
... ]
|
||||
>>> dist, _ = floyd_warshall(graph, num_vertices)
|
||||
>>> dist == expected
|
||||
|
|
|
@ -18,24 +18,10 @@ def test_no_edges():
|
|||
assert dist == expected
|
||||
|
||||
|
||||
def test_example_input(capsys):
|
||||
num_vertices = 3
|
||||
graph = [
|
||||
[float("inf"), float("inf"), float("inf")],
|
||||
[float("inf"), float("inf"), float("inf")],
|
||||
[float("inf"), float("inf"), float("inf")],
|
||||
]
|
||||
for i in range(num_vertices):
|
||||
graph[i][i] = 0.0
|
||||
graph[0][1] = 2
|
||||
graph[1][0] = 1
|
||||
expected = [
|
||||
[0, 2, float("inf")],
|
||||
[1, 0, float("inf")],
|
||||
[float("inf"), float("inf"), 0],
|
||||
]
|
||||
dist, _ = floyd_warshall(graph, num_vertices)
|
||||
_ = capsys.readouterr()
|
||||
def test_with_edges():
|
||||
graph = [[0, 3, float("inf")], [2, 0, float("inf")], [float("inf"), 7, 0]]
|
||||
expected = [[0, 3, float("inf")], [2, 0, float("inf")], [9, 7, 0]]
|
||||
dist, _ = floyd_warshall(graph, 3)
|
||||
assert dist == expected
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user