Skip to main content

is_tournament

Function is_tournament 

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

Check whether a graph is a tournament.

A tournament is a complete asymmetric directed graph: for every pair of distinct vertices, exactly one directed edge exists.

Returns false for undirected graphs. Returns true for the empty graph and single-vertex graph (vacuously).

§Examples

use rust_igraph::{Graph, is_tournament};

// Directed 3-cycle: 0→1, 1→2, 2→0 — a tournament
let mut g = Graph::new(3, true).unwrap();
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 0).unwrap();
assert!(is_tournament(&g).unwrap());

// Undirected triangle is NOT a tournament
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 0).unwrap();
assert!(!is_tournament(&g).unwrap());