Skip to content

Commit e7e2971

Browse files
authored
Fix error messages in TSP validation functions
1 parent 3ca9a00 commit e7e2971

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

graphs/travelling_salesman_problem.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def euclidean_distance(point1: list[float], point2: list[float]) -> float:
2222
0.0
2323
>>> euclidean_distance([1, 1], ['a', 1])
2424
Traceback (most recent call last):
25-
...
25+
...
2626
ValueError: Invalid input: Points must be numerical coordinates
2727
"""
2828
try:
@@ -42,17 +42,17 @@ def validate_graph(graph_points: dict[str, list[float]]) -> None:
4242
>>> validate_graph({"A": [10, 20], "B": [30, 21], "C": [15, 35]}) # Valid graph
4343
>>> validate_graph({"A": [10, 20], "B": [30, "invalid"], "C": [15, 35]})
4444
Traceback (most recent call last):
45-
...
45+
...
4646
InvalidGraphError: Each node must have a valid 2D coordinate [x, y]
4747
4848
>>> validate_graph([10, 20]) # Invalid input type
4949
Traceback (most recent call last):
50-
...
50+
...
5151
InvalidGraphError: Graph must be a dictionary with node names and coordinates
5252
5353
>>> validate_graph({"A": [10, 20], "B": [30, 21], "C": [15]}) # Missing coordinate
5454
Traceback (most recent call last):
55-
...
55+
...
5656
InvalidGraphError: Each node must have a valid 2D coordinate [x, y]
5757
"""
5858
if not isinstance(graph_points, dict):

0 commit comments

Comments
 (0)