GithubHelp home page GithubHelp logo

binfang2014 / minimum-cost-perfect-matching Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dilsonpereira/minimum-cost-perfect-matching

0.0 0.0 0.0 31 KB

C++ implementation of algorithms for finding perfect matchings in general graphs

License: MIT License

C++ 100.00%

minimum-cost-perfect-matching's Introduction

Algorithms for Maximum Cardinality Matching and Minimum Cost Perfect Matching Problems in General Graphs

I implemented these algorithms during my PhD, in 2011, following the description in:

Gerards, A.M.H. (1995). Matching. In Ball, M., Magnanti, T., Monma, C., and Nemhauser, G., editors, Network Models, volume 7 of Handbooks in Operations Research and Management Science, chapter 3, pages 135-224. Elsevier.

See Example.cpp for examples of how to use the API.

Compilation with G++:

g++ -O3 Example.cpp BinaryHeap.cpp Matching.cpp Graph.cpp -o example

To use as a matching solver:

./example -f <filename> <--minweight | --max>

--minweight for minimum weight perfect matching

--max for maximum cardinality matching

File format:

the first two lines give n (number of vertices) and m (number of edges), respectively, followed by m lines, each with a tuple (u, v [, c]) representing the edges. In each tuple, u and v are the endpoints (0-based indexing) of the edge and c is its cost. The cost is optional if --max is specified.

Example, input.txt:

10
16
0 1 10
0 2 4
1 2 3
1 5 2
1 6 2
2 3 1
2 4 2
3 4 5
4 6 4
4 7 1
4 8 3
5 6 1
6 7 2
7 8 3
7 9 2
8 9 1
./example -f input.txt --minweight

Output:

Optimal matching cost: 14
Edges in the matching:
0 1
2 3
4 7
5 6
8 9

Feel free to contact me if you have any problem.

minimum-cost-perfect-matching's People

Contributors

dilsonpereira avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.