-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maximum weighted matching #23
Conversation
Codecov Report
@@ Coverage Diff @@
## master #23 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 13 14 +1
Lines 210 234 +24
=====================================
+ Hits 210 234 +24
Continue to review full report at Codecov.
|
src/matching/matching.jl
Outdated
@@ -1,7 +1,7 @@ | |||
__precompile__(true) | |||
module Matching | |||
using LightGraphs | |||
export MatchingResult, maximum_weight_maximal_matching, minimum_weight_perfect_matching | |||
export MatchingResult, max_weight_matching, maximum_weight_maximal_matching, minimum_weight_perfect_matching |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_weight_matching->maximum_weight_matching
for coerence with the other functions
src/matching/max_weight_matching.jl
Outdated
|
||
Given a graph `g` and an edgemap `w` containing weights associated to edges, | ||
returns a matching with the maximum total weight. | ||
`w` is a dictionnary that maps edges i => j (with i <= j) to weights. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo here
"- If the graph is not bipartite, then the computation time may grow exponentially." I do not see integer programming part in case of fractionary solution, why do you say that? I see three options here:
|
also, coverage should be increased |
Sorry I wasn't clear in my comments, the integer programming is taken care of by the solver (by using the Int keyword in @variable, line 45). |
|
||
Given a graph `g` and an edgemap `w` containing weights associated to edges, | ||
returns a matching with the maximum total weight. | ||
`w` is a dictionnary that maps edges i => j to weights. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dictionnary->dictionary
The package JuMP.jl and one of its supported solvers is required. | ||
|
||
Returns MatchingResult containing: | ||
- a solve status (indicating whether the problem was solved to optimality) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MatchingResult doesn't contain solve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I saw the TODO comment
Returns MatchingResult containing: | ||
- a solve status (indicating whether the problem was solved to optimality) | ||
- the optimal cost | ||
- a list of each node's match. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> a list of each vertex's match (or -1 for unmatched vertices)
test/matching/runtests.jl
Outdated
w[Edge(1,3)] = 1 | ||
w[Edge(1,4)] = 3 | ||
w[Edge(2,4)] = 1 | ||
match = Matching.maximum_weight_matching(g,w) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove Matching. from here and from the other lines in this file (also a check to see that everything is correctly exported)
Ok, thanks for the clarification, my knowledge of JuMP is very limited. This looks good, i can be merged once the remaining comments are addressed |
this case should be tested if setdiff(edge_list, keys(w)) != [] # If some edges do not have a key in w.
error("Some edge weights are missing, check that keys i => j in w satisfy i <= j")
end with a @test_throws ErrorException .... |
Just a quick follow-up: can this PR be merged? |
Hi,
This is a formulation for maximum weighted matching, works for both bipartite and non-bipartite graphs.
In the case of bipartite graphs, the solution of the LP is automatically integral (i.e. no need to enforce integrality constraints).
In the case of non-bipartite graphs, it requires an MIP solver (e.g. GLPK) and may therefore be much slower to solve to optimality.
Disclaimer: This is the first time I do a pull request, so I hope I'm not missing an important step.