#matching #graph #edge #general #undirected #weighted #compute

mwmatching

Maximum-Weight Matching: Compute a maximum-weighted matching in the general undirected weighted graph given by 'edges'

2 releases

Uses old Rust 2015

0.1.1 Jul 11, 2018
0.1.0 Jun 28, 2018

#476 in Science

Download history 105/week @ 2023-12-17 23/week @ 2023-12-24 102/week @ 2023-12-31 112/week @ 2024-01-07 300/week @ 2024-01-14 215/week @ 2024-01-21 63/week @ 2024-01-28 106/week @ 2024-02-04 70/week @ 2024-02-11 58/week @ 2024-02-18 93/week @ 2024-02-25 95/week @ 2024-03-03 72/week @ 2024-03-10 61/week @ 2024-03-17 33/week @ 2024-03-24 105/week @ 2024-03-31

275 downloads per month

MIT license

53KB
780 lines

mwmatching

Weighted maximum matching in general graphs.

This is a Rust re-implementation of a Python program by Joris van Rantwijk. Nearly all of the comments are taken directly from that version. For the original code, go to http://jorisvr.nl/article/maximum-matching.

Compute a maximum-weighted matching in the general undirected weighted graph given by "edges".
General usage:

  let mates = Matching::new(edges).solve();

or

  let mates = Matching::new(edges).max_cardinality().solve();

If "max_cardinality()" is used, then only maximum-cardinality matchings are considered as solutions.

Edges is a sequence of tuples (i, j, wt) describing an undirected edge between vertex i and vertex j with weight wt. Currently, wt must be an i32. There is at most one edge between any two vertices; no vertex has an edge to itself. Vertices are identified by consecutive, non-negative integers (usize).

Returns a list "mates", such that mates[i] == j if vertex i is matched to vertex j, and mates[i] == SENTINEL if vertex i is not matched, where SENTINEL is usize::max_value().

No runtime deps