Skip to content

Commit 8be7753

Browse files
author
Ajmera, Mahita SI/HZR-IDSA
committed
changing pytest
1 parent e1eb17e commit 8be7753

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

graphs/graphs_floyd_warshall.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,16 @@ def floyd_warshall(graph, v):
3333
updated to the next vertex[i][k].
3434
3535
36-
>>> num_vertices = 3
3736
>>> graph = [
38-
... [float('inf'), float('inf'), float('inf')],
39-
... [float('inf'), float('inf'), float('inf')],
40-
... [float('inf'), float('inf'), float('inf')]
37+
... [0, 3, float('inf')],
38+
... [2, 0, float('inf')],
39+
... [float('inf'), 7, 0]
4140
... ]
4241
4342
>>> expected = [
44-
... [0, 2, float('inf')],
45-
... [1, 0, float('inf')],
46-
... [float('inf'), float('inf'), 0]
43+
... [0, 3, float('inf')],
44+
... [2, 0, float('inf')],
45+
... [9, 7, 0]
4746
... ]
4847
>>> dist, _ = floyd_warshall(graph, num_vertices)
4948
>>> dist == expected

graphs/tests/test_graphs_floyd_warshall.py

+4-18
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,10 @@ def test_no_edges():
1818
assert dist == expected
1919

2020

21-
def test_example_input(capsys):
22-
num_vertices = 3
23-
graph = [
24-
[float("inf"), float("inf"), float("inf")],
25-
[float("inf"), float("inf"), float("inf")],
26-
[float("inf"), float("inf"), float("inf")],
27-
]
28-
for i in range(num_vertices):
29-
graph[i][i] = 0.0
30-
graph[0][1] = 2
31-
graph[1][0] = 1
32-
expected = [
33-
[0, 2, float("inf")],
34-
[1, 0, float("inf")],
35-
[float("inf"), float("inf"), 0],
36-
]
37-
dist, _ = floyd_warshall(graph, num_vertices)
38-
_ = capsys.readouterr()
21+
def test_with_edges():
22+
graph = [[0, 3, float("inf")], [2, 0, float("inf")], [float("inf"), 7, 0]]
23+
expected = [[0, 3, float("inf")], [2, 0, float("inf")], [9, 7, 0]]
24+
dist, _ = floyd_warshall(graph, 3)
3925
assert dist == expected
4026

4127

0 commit comments

Comments
 (0)