Skip to main content

is_geodetic

Function is_geodetic 

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

Check whether a graph is geodetic.

A geodetic graph has exactly one shortest path between every pair of connected vertices.

For directed graphs, paths follow edge direction; unreachable pairs are ignored.

An empty graph (0 vertices) is geodetic (vacuously). A single vertex is geodetic. Any tree is geodetic.

ยงExamples

use rust_igraph::{Graph, is_geodetic};

// Tree (path): geodetic
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_geodetic(&g).unwrap());

// C4 is NOT geodetic (two shortest paths between opposite vertices)
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();
g.add_edge(3, 0).unwrap();
assert!(!is_geodetic(&g).unwrap());