Skip to main content

is_fork_free

Function is_fork_free 

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

Check whether a graph is fork-free (no induced fork / cross).

The fork is a claw (K_{1,3}) with one edge subdivided: center c adjacent to a, b, d, and d also adjacent to e. No other edges among {c, a, b, d, e}.

Returns false for directed graphs.

ยงExamples

use rust_igraph::{Graph, is_fork_free};

// Path `P_4` is fork-free
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_fork_free(&g).unwrap());

// Fork: center 0, arms 1, 2, 3, pendant 3-4
let mut g = Graph::with_vertices(5);
g.add_edge(0, 1).unwrap();
g.add_edge(0, 2).unwrap();
g.add_edge(0, 3).unwrap();
g.add_edge(3, 4).unwrap();
assert!(!is_fork_free(&g).unwrap());