Skip to content

Commit b4daa60

Browse files
committed
add test for shortestpath
1 parent 166f347 commit b4daa60

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

test/testshortestpath.jl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,44 @@
2727
@test element in CorrectShortestPath
2828
end
2929
end
30+
31+
32+
@testset "Simple Problem 2" begin
33+
problem = ShortestPathProblem(
34+
Connection[
35+
Connection(1, 2, 2),
36+
Connection(1, 3, 3),
37+
Connection(1, 4, 4),
38+
Connection(2, 3, 1),
39+
Connection(3, 4, 1),
40+
Connection(2, 5, 4),
41+
Connection(3, 7, 2),
42+
Connection(4, 6, 3),
43+
Connection(6, 7, 1),
44+
Connection(5, 7, 3),
45+
Connection(5, 8, 8),
46+
Connection(6, 9, 7),
47+
Connection(8, 10, 5),
48+
Connection(9, 10, 6),
49+
Connection(7, 10, 10),
50+
]
51+
)
52+
53+
# Shortest path: 1 -> 3 -> 7 -> 10
54+
CorrectShortestPath = [
55+
problem.connections[2],
56+
problem.connections[7],
57+
problem.connections[15]]
58+
59+
result = solve(problem)
60+
61+
display(result)
62+
@test result isa ShortestPathResult
63+
@test result.cost == 15.0
64+
65+
for element in result.path
66+
@test element in CorrectShortestPath
67+
end
68+
69+
end
3070
end

0 commit comments

Comments
 (0)