|
1 | | -@testset "Parallel.Dijkstra" begin |
| 1 | +@testset "Parallel.Dijkstra" for parallel in [:threads, :distributed] |
2 | 2 | g4 = path_digraph(5) |
3 | 3 | d1 = float([0 1 2 3 4; 5 0 6 7 8; 9 10 0 11 12; 13 14 15 0 16; 17 18 19 20 0]) |
4 | 4 | d2 = sparse(float([0 1 2 3 4; 5 0 6 7 8; 9 10 0 11 12; 13 14 15 0 16; 17 18 19 20 0])) |
|
8 | 8 |
|
9 | 9 | for g in testgraphs(g3) |
10 | 10 | z = floyd_warshall_shortest_paths(g, d) |
11 | | - zp = @inferred(Parallel.dijkstra_shortest_paths(g, collect(1:5), d)) |
| 11 | + zp = @inferred(Parallel.dijkstra_shortest_paths(g, collect(1:5), d; parallel)) |
12 | 12 | @test all(isapprox(z.dists, zp.dists)) |
13 | 13 |
|
14 | 14 | for i in 1:5 |
|
21 | 21 | end |
22 | 22 |
|
23 | 23 | z = floyd_warshall_shortest_paths(g) |
24 | | - zp = @inferred(Parallel.dijkstra_shortest_paths(g)) |
| 24 | + zp = @inferred(Parallel.dijkstra_shortest_paths(g; parallel)) |
25 | 25 | @test all(isapprox(z.dists, zp.dists)) |
26 | 26 |
|
27 | 27 | for i in 1:5 |
|
34 | 34 | end |
35 | 35 |
|
36 | 36 | z = floyd_warshall_shortest_paths(g) |
37 | | - zp = @inferred(Parallel.dijkstra_shortest_paths(g, [1, 2])) |
| 37 | + zp = @inferred(Parallel.dijkstra_shortest_paths(g, [1, 2]; parallel)) |
38 | 38 | @test all(isapprox(z.dists[1:2, :], zp.dists)) |
39 | 39 |
|
40 | 40 | for i in 1:2 |
|
51 | 51 | g3 = path_digraph(5) |
52 | 52 | d = float([0 1 2 3 4; 5 0 6 7 8; 9 10 0 11 12; 13 14 15 0 16; 17 18 19 20 0]) |
53 | 53 |
|
| 54 | + # An error should be reported if the parallel mode could not be understood |
| 55 | + @test_throws ArgumentError Parallel.dijkstra_shortest_paths( |
| 56 | + testdigraphs(g3)[1], collect(1:5), d; parallel=:thread |
| 57 | + ) |
| 58 | + @test_throws ArgumentError Parallel.dijkstra_shortest_paths( |
| 59 | + testdigraphs(g3)[1], collect(1:5), d; parallel=:distriibuted |
| 60 | + ) |
| 61 | + |
54 | 62 | for g in testdigraphs(g3) |
55 | 63 | z = floyd_warshall_shortest_paths(g, d) |
56 | | - zp = @inferred(Parallel.dijkstra_shortest_paths(g, collect(1:5), d)) |
| 64 | + zp = @inferred(Parallel.dijkstra_shortest_paths(g, collect(1:5), d; parallel)) |
57 | 65 | @test all(isapprox(z.dists, zp.dists)) |
58 | 66 |
|
59 | 67 | for i in 1:5 |
|
66 | 74 | end |
67 | 75 |
|
68 | 76 | z = floyd_warshall_shortest_paths(g) |
69 | | - zp = @inferred(Parallel.dijkstra_shortest_paths(g)) |
| 77 | + zp = @inferred(Parallel.dijkstra_shortest_paths(g; parallel)) |
70 | 78 | @test all(isapprox(z.dists, zp.dists)) |
71 | 79 |
|
72 | 80 | for i in 1:5 |
|
79 | 87 | end |
80 | 88 |
|
81 | 89 | z = floyd_warshall_shortest_paths(g) |
82 | | - zp = @inferred(Parallel.dijkstra_shortest_paths(g, [1, 2])) |
| 90 | + zp = @inferred(Parallel.dijkstra_shortest_paths(g, [1, 2]; parallel)) |
83 | 91 | @test all(isapprox(z.dists[1:2, :], zp.dists)) |
84 | 92 |
|
85 | 93 | for i in 1:2 |
|
0 commit comments