1
+ using Test, ProblemReductions, Graphs
2
+
3
+ @testset " matching_setpacking" begin
4
+
5
+ # UnitWeight Graph
6
+ g1 = SimpleGraph (4 )
7
+ for (i, j) in [(1 , 2 ), (1 , 3 ), (3 , 4 ), (2 , 3 )]
8
+ add_edge! (g1, i, j)
9
+ end
10
+ Matching1 = Matching (g1)
11
+ SP1 = reduceto (SetPacking, Matching1)
12
+ @test target_problem (SP1) == SP1. setpacking
13
+ @test target_problem (SP1) == SetPacking ([[1 ,2 ], [1 ,3 ],[2 ,3 ] ,[3 ,4 ]], [1 , 1 , 1 , 1 ])
14
+ sol = findbest (SP1. setpacking, BruteForce ())
15
+ @test extract_solution (SP1, sol) == sol
16
+
17
+ # Weighted Graph
18
+ g2 = SimpleGraph (4 )
19
+ for (i, j) in [(1 , 2 ), (1 , 3 ), (3 , 4 ), (2 , 3 )]
20
+ add_edge! (g2, i, j)
21
+ end
22
+ Matching2 = Matching (g2, [1 , 2 , 3 , 4 ])
23
+ SP2 = reduceto (SetPacking, Matching2)
24
+ @test target_problem (SP2) == SP2. setpacking
25
+ @test target_problem (SP2) == SetPacking ([[1 ,2 ], [1 ,3 ], [2 ,3 ], [3 ,4 ]], [1 , 2 , 3 , 4 ])
26
+ sol1 = findbest (SP2. setpacking, BruteForce ())
27
+ sol2 = findbest (Matching2,BruteForce ())
28
+ @test extract_solution (SP2, sol1) == sol2
29
+ end
0 commit comments