|
139 | 139 | @test match.weight ≈ 2
|
140 | 140 |
|
141 | 141 | end
|
142 |
| - |
143 |
| - |
144 |
| - |
145 |
| - @testset "minimum_weight_perfect_matching" begin |
146 |
| - algos = Any[LEMONMWPMAlgorithm()] |
147 |
| - @static if !Sys.iswindows() && Sys.ARCH == :x86_64 |
148 |
| - push!(algos, BlossomVAlgorithm()) |
149 |
| - end |
150 |
| - for algorithm in algos |
151 |
| - |
152 |
| - w = Dict(Edge(1, 2) => 500) |
153 |
| - g = Graph(2) |
154 |
| - add_edge!(g, 1, 2) |
155 |
| - match = minimum_weight_perfect_matching(g, w, algorithm) |
156 |
| - @test match.mate[1] == 2 |
157 |
| - |
158 |
| - |
159 |
| - w = Dict( |
160 |
| - Edge(1, 2) => 500, |
161 |
| - Edge(1, 3) => 600, |
162 |
| - Edge(2, 3) => 700, |
163 |
| - Edge(3, 4) => 100, |
164 |
| - Edge(2, 4) => 1000, |
165 |
| - ) |
166 |
| - |
167 |
| - g = complete_graph(4) |
168 |
| - match = minimum_weight_perfect_matching(g, w, algorithm) |
169 |
| - @test match.mate[1] == 2 |
170 |
| - @test match.mate[2] == 1 |
171 |
| - @test match.mate[3] == 4 |
172 |
| - @test match.mate[4] == 3 |
173 |
| - @test match.weight ≈ 600 |
174 |
| - |
175 |
| - w = Dict( |
176 |
| - Edge(1, 2) => 500, |
177 |
| - Edge(1, 3) => 400, |
178 |
| - Edge(2, 3) => 300, |
179 |
| - Edge(3, 4) => 1000, |
180 |
| - Edge(2, 4) => 1000, |
181 |
| - ) |
182 |
| - g = complete_graph(4) |
183 |
| - match = minimum_weight_perfect_matching(g, w, algorithm) |
184 |
| - @test match.mate[1] == 3 |
185 |
| - @test match.mate[2] == 4 |
186 |
| - @test match.mate[3] == 1 |
187 |
| - @test match.mate[4] == 2 |
188 |
| - @test match.weight ≈ 1400 |
189 |
| - |
190 |
| - g = complete_bipartite_graph(2, 2) |
191 |
| - w = Dict{Edge,Float64}() |
192 |
| - w[Edge(1, 3)] = -10 |
193 |
| - w[Edge(1, 4)] = -0.5 |
194 |
| - w[Edge(2, 3)] = -11 |
195 |
| - w[Edge(2, 4)] = -1 |
196 |
| - |
197 |
| - match = minimum_weight_perfect_matching(g, w, algorithm) |
198 |
| - @test match.mate[1] == 4 |
199 |
| - @test match.mate[4] == 1 |
200 |
| - @test match.mate[2] == 3 |
201 |
| - @test match.mate[3] == 2 |
202 |
| - @test match.weight ≈ -11.5 |
203 |
| - |
204 |
| - |
205 |
| - g = complete_graph(4) |
206 |
| - w = Dict{Edge,Float64}() |
207 |
| - w[Edge(1, 3)] = 10 |
208 |
| - w[Edge(1, 4)] = 0.5 |
209 |
| - w[Edge(2, 3)] = 11 |
210 |
| - w[Edge(2, 4)] = 2 |
211 |
| - w[Edge(1, 2)] = 100 |
212 |
| - |
213 |
| - match = minimum_weight_perfect_matching(g, w, 50, algorithm) |
214 |
| - @test match.mate[1] == 4 |
215 |
| - @test match.mate[4] == 1 |
216 |
| - @test match.mate[2] == 3 |
217 |
| - @test match.mate[3] == 2 |
218 |
| - @test match.weight ≈ 11.5 |
219 |
| - |
220 |
| - # Issue #5 |
221 |
| - g = Graph(Graph([Edge(1, 2), Edge(2, 3), Edge(4, 1)])) |
222 |
| - w = Dict(Edge(1, 2) => 2.0, Edge(2, 3) => 2.0, Edge(1, 4) => 2.0) |
223 |
| - match = minimum_weight_perfect_matching(g, w) |
224 |
| - @test match.mate == [4, 3, 2, 1] |
225 |
| - @test match.weight == 4.0 |
226 |
| - |
227 |
| - g = Graph([Edge(1, 2)]) |
228 |
| - wFloat = Dict(Edge(1, 2) => 2.0) |
229 |
| - wInt = Dict(Edge(1, 2) => 2) |
230 |
| - matchFloat = minimum_weight_perfect_matching(g, wFloat, algorithm) |
231 |
| - matchInt = minimum_weight_perfect_matching(g, wInt, algorithm) |
232 |
| - @test matchFloat.mate == matchInt.mate |
233 |
| - @test matchFloat.weight == matchInt.weight |
234 |
| - |
235 |
| - end |
236 |
| - end |
237 | 142 | end
|
0 commit comments