Skip to main content

greedy_matching

Function greedy_matching 

Source
pub fn greedy_matching(graph: &Graph) -> IgraphResult<Vec<usize>>
Expand description

Find a greedy maximal matching.

Iterates over edges and greedily adds each edge whose endpoints are both unmatched. Returns edge indices of the matching.

The result is maximal (no edge can be added) but not necessarily maximum.

ยงExamples

use rust_igraph::{Graph, greedy_matching};

let g = Graph::from_edges(&[(0,1),(1,2),(2,3)], false, Some(4)).unwrap();
let m = greedy_matching(&g).unwrap();
assert!(!m.is_empty());