Skip to content

Commit 7ab77b0

Browse files
committed
readme
1 parent 871617a commit 7ab77b0

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,47 @@
66

77
[![codecov](https://codecov.io/gh/JuliaGraphs/LightGraphsMatching.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaGraphs/LightGraphsMatching.jl)
88

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+
```

0 commit comments

Comments
 (0)