Skip to content

Commit ed8b6e3

Browse files
committed
add-tsp-problem
2 parents a766f38 + c7be8c0 commit ed8b6e3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

graphs/tests/test_traveling_salesman_problem.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ def sample_graph_2() -> list[list[int]]:
1717
[20, 25, 30, 0],
1818
]
1919

20+
2021
def test_brute_force() -> None:
2122
graph = sample_graph_1()
2223
assert tsp_brute_force(graph) == 64
2324

25+
2426
def test_dp() -> None:
2527
graph = sample_graph_1()
2628
assert tsp_dp(graph) == 64
2729

30+
2831
def test_greedy() -> None:
2932
graph = sample_graph_1()
3033
# The greedy algorithm does not guarantee an optimal solution;
@@ -35,6 +38,7 @@ def test_greedy() -> None:
3538
assert isinstance(result, int)
3639
assert result >= 64
3740

41+
3842
def test_dp_larger_graph() -> None:
3943
graph = sample_graph_2()
4044
assert tsp_dp(graph) == 80
@@ -44,6 +48,7 @@ def test_brute_force_larger_graph() -> None:
4448
graph = sample_graph_2()
4549
assert tsp_brute_force(graph) == 80
4650

51+
4752
def test_greedy_larger_graph() -> None:
4853
graph = sample_graph_2()
4954
result = tsp_greedy(graph)

0 commit comments

Comments
 (0)