Skip to main content

is_semicomplete

Function is_semicomplete 

Source
pub fn is_semicomplete(graph: &Graph) -> IgraphResult<bool>
Expand description

Check whether a directed graph is semicomplete.

A semicomplete digraph has at least one arc between every pair of distinct vertices. This generalizes tournaments (which forbid bidirectional edges).

Returns false for undirected graphs.

ยงExamples

use rust_igraph::{Graph, is_semicomplete};

// Tournament on 3 vertices: 0โ†’1, 1โ†’2, 0โ†’2
let mut g = Graph::new(3, true).unwrap();
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(0, 2).unwrap();
assert!(is_semicomplete(&g).unwrap());

// Missing arc between 0 and 2
let mut g = Graph::new(3, true).unwrap();
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
assert!(!is_semicomplete(&g).unwrap());