File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 6
6
7
7
[ ![ codecov] ( https://codecov.io/gh/JuliaGraphs/LightGraphsMatching.jl/branch/master/graph/badge.svg )] ( https://codecov.io/gh/JuliaGraphs/LightGraphsMatching.jl )
8
8
9
+ Matching algorithms on top of [ LightGraphs] ( https://github.com/JuliaGraphs/LightGraphs ) .
10
+
11
+ ## Usage
12
+
13
+ The results of any matching is returned as a ` MatchingResult ` struct
14
+ containing the ` mate ` and ` weight ` fields.
15
+
16
+ ### Perfect matching
17
+
18
+ ``` julia
19
+ g = CompleteGraph (4 )
20
+ w = Dict {Edge,Float64} ()
21
+ w[Edge (1 ,3 )] = 10
22
+ w[Edge (1 ,4 )] = 0.5
23
+ w[Edge (2 ,3 )] = 11
24
+ w[Edge (2 ,4 )] = 2
25
+ w[Edge (1 ,2 )] = 100
26
+
27
+ # find the perfect matching of minimum weight
28
+ match = minimum_weight_perfect_matching (g, w, 50 )
29
+ # match.mate[1] == 4
30
+ # match.mate[4] == 1
31
+ # match.mate[2] == 3
32
+ # match.mate[3] == 2
33
+ # match.weight ≈ 11.5
34
+ ```
35
+
36
+ ### Maximum weight matching
37
+
38
+ A maximum weight matching is solved as a Linear Programming
39
+ problem and requires a LP solver respecting the [ MathProgBase] ( https://github.com/JuliaOpt/MathProgBase.jl ) solver
40
+ interface. See MathProgBase
41
+ [ documentation] ( http://mathprogbasejl.readthedocs.io/en/latest/solvers.html ) for more details.
42
+
43
+ ``` julia
44
+ using Cbc: CbcSolver # import a LP solver
45
+ g = CompleteGraph (3 )
46
+ w = zeros (3 ,3 )
47
+ w[1 ,2 ] = 1
48
+ w[3 ,2 ] = 1
49
+ w[1 ,3 ] = 1
50
+ match = maximum_weight_matching (g,CbcSolver (),w)
51
+ # match.weight ≈ 1
52
+ ```
You can’t perform that action at this time.
0 commit comments