Skip to main content

is_independent_vertex_set

Function is_independent_vertex_set 

Source
pub fn is_independent_vertex_set(
    graph: &Graph,
    vertices: &[VertexId],
) -> IgraphResult<bool>
Expand description

Check whether a set of vertices forms an independent set.

An independent set is a set of vertices in which no pair is adjacent. An empty set and a singleton set are always considered independent sets.

Edge directions are ignored — any edge between two vertices in the set disqualifies it.

§Examples

use rust_igraph::{Graph, is_independent_vertex_set};

let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(2, 3).unwrap();
assert!(is_independent_vertex_set(&g, &[0, 2]).unwrap());
assert!(!is_independent_vertex_set(&g, &[0, 1]).unwrap());