|
14 | 14 | max_vec_mst = Vector{Edge}([Edge(1, 4), Edge(2, 4), Edge(1, 3)]) |
15 | 15 | cost_max_vec_mst = sum(distmx[src(e), dst(e)] for e in max_vec_mst) |
16 | 16 |
|
17 | | - for g in testgraphs(g4) |
| 17 | + for g in test_generic_graphs(g4) |
18 | 18 | # Testing Boruvka's algorithm |
19 | 19 | res1 = boruvka_mst(g, distmx) |
20 | | - g1t = SimpleGraph(res1.mst) |
| 20 | + edges1 = [Edge(src(e), dst(e)) for e in res1.mst] |
| 21 | + g1t = GenericGraph(SimpleGraph(edges1)) |
21 | 22 | @test res1.weight == cost_mst |
22 | 23 | # acyclic graphs have n - c edges |
23 | 24 | @test nv(g1t) - length(connected_components(g1t)) == ne(g1t) |
24 | 25 | @test nv(g1t) == nv(g) |
25 | 26 |
|
26 | 27 | res2 = boruvka_mst(g, distmx; minimize=false) |
27 | | - g2t = SimpleGraph(res2.mst) |
| 28 | + edges2 = [Edge(src(e), dst(e)) for e in res2.mst] |
| 29 | + g2t = GenericGraph(SimpleGraph(edges2)) |
28 | 30 | @test res2.weight == cost_max_vec_mst |
29 | 31 | @test nv(g2t) - length(connected_components(g2t)) == ne(g2t) |
30 | 32 | @test nv(g2t) == nv(g) |
|
53 | 55 | ]) |
54 | 56 | weight_max_vec2 = sum(distmx_sec[src(e), dst(e)] for e in max_vec2) |
55 | 57 |
|
56 | | - for g in testgraphs(gx) |
| 58 | + for g in test_generic_graphs(gx) |
57 | 59 | res3 = boruvka_mst(g, distmx_sec) |
58 | | - g3t = SimpleGraph(res3.mst) |
| 60 | + edges3 = [Edge(src(e), dst(e)) for e in res3.mst] |
| 61 | + g3t = GenericGraph(SimpleGraph(edges3)) |
59 | 62 | @test res3.weight == weight_vec2 |
60 | 63 | @test nv(g3t) - length(connected_components(g3t)) == ne(g3t) |
61 | 64 | @test nv(g3t) == nv(gx) |
62 | 65 |
|
63 | 66 | res4 = boruvka_mst(g, distmx_sec; minimize=false) |
64 | | - g4t = SimpleGraph(res4.mst) |
| 67 | + edges4 = [Edge(src(e), dst(e)) for e in res4.mst] |
| 68 | + g4t = GenericGraph(SimpleGraph(edges4)) |
65 | 69 | @test res4.weight == weight_max_vec2 |
66 | 70 | @test nv(g4t) - length(connected_components(g4t)) == ne(g4t) |
67 | 71 | @test nv(g4t) == nv(gx) |
|
114 | 118 | ]) |
115 | 119 | weight_max_vec3 = sum(distmx_third[src(e), dst(e)] for e in max_vec3) |
116 | 120 |
|
117 | | - for g in testgraphs(gd) |
| 121 | + for g in test_generic_graphs(gd) |
118 | 122 | res5 = boruvka_mst(g, distmx_third) |
119 | | - g5t = SimpleGraph(res5.mst) |
| 123 | + edges5 = [Edge(src(e), dst(e)) for e in res5.mst] |
| 124 | + g5t = GenericGraph(SimpleGraph(edges5)) |
120 | 125 | @test res5.weight == weight_vec3 |
121 | 126 | @test nv(g5t) - length(connected_components(g5t)) == ne(g5t) |
122 | 127 | @test nv(g5t) == nv(gd) |
123 | 128 |
|
124 | 129 | res6 = boruvka_mst(g, distmx_third; minimize=false) |
125 | | - g6t = SimpleGraph(res6.mst) |
| 130 | + edges6 = [Edge(src(e), dst(e)) for e in res6.mst] |
| 131 | + g6t = GenericGraph(SimpleGraph(edges6)) |
126 | 132 | @test res6.weight == weight_max_vec3 |
127 | 133 | @test nv(g6t) - length(connected_components(g6t)) == ne(g6t) |
128 | 134 | @test nv(g6t) == nv(gd) |
|
0 commit comments