stable_matching_distance

Function stable_matching_distance 

Source
pub fn stable_matching_distance<T, U, N: Ord + Copy, V: Clone + Fn(&T, &U) -> N>(
    proposers: &[T],
    receivers: &[U],
    value_func: V,
) -> Vec<(usize, usize)>
Expand description

Implements the Gale-Shapley algorithm, as described on page 6 of Algorithm Design by Kleinberg and Tardos.

Preferences are ranked in terms of distance function values from value_func(proposer, receiver), with lower values indicating higher preferences.

Returns a Vec containing pairs of indices from the input slices, with the proposer index first.