Skip to main content

is_vertex_cover

Function is_vertex_cover 

Source
pub fn is_vertex_cover(graph: &Graph, cover: &[VertexId]) -> bool
Expand description

Check whether a set of vertices forms a valid vertex cover.

A vertex cover is valid if every edge in the graph has at least one endpoint in the set.

ยงExamples

use rust_igraph::{Graph, is_vertex_cover};

let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();

assert!(is_vertex_cover(&g, &[1, 2]));
assert!(!is_vertex_cover(&g, &[0, 3]));