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

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

#584 in Science

Download history 76/week @ 2024-03-13 57/week @ 2024-03-20 62/week @ 2024-03-27 71/week @ 2024-04-03 37/week @ 2024-04-10 30/week @ 2024-04-17 48/week @ 2024-04-24 156/week @ 2024-05-01 85/week @ 2024-05-08 43/week @ 2024-05-15 34/week @ 2024-05-22 29/week @ 2024-05-29 51/week @ 2024-06-05 72/week @ 2024-06-12 44/week @ 2024-06-19 62/week @ 2024-06-26

237 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