Skip to content

Commit 218a8cf

Browse files
committed
add test for shortest path problem (two way connections)
1 parent 48554f5 commit 218a8cf

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/testshortestpath.jl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,36 @@
6666
end
6767

6868
end
69+
70+
@testset "Simple Problem - Two way connections" begin
71+
problem = ShortestPathProblem(
72+
Connection[
73+
Connection(1, 2, 4), #1
74+
Connection(1, 3, 15), #2
75+
76+
# Two way connection
77+
Connection(2, 3, 2), #3
78+
Connection(3, 2, 3), #4
79+
80+
Connection(2, 4, 15), #5
81+
Connection(3, 4, 6), #6
82+
]
83+
)
84+
85+
# Shortest path: 1 -> 2 -> 3 -> 4
86+
CorrectShortestPath = [
87+
problem.connections[1],
88+
problem.connections[3],
89+
problem.connections[6]]
90+
91+
result = solve(problem)
92+
93+
@test result isa ShortestPathResult
94+
@test result.cost == 12.0
95+
96+
for element in result.path
97+
@test element in CorrectShortestPath
98+
end
99+
100+
end
69101
end

0 commit comments

Comments
 (0)