Skip to main content

hyperbolicity_twice

Function hyperbolicity_twice 

Source
pub fn hyperbolicity_twice(graph: &Graph) -> Result<u32, IgraphError>
Expand description

Compute the Gromov δ-hyperbolicity of a graph.

Returns as an integer (since δ is always a half-integer). To get the actual δ, divide by 2. Trees have 2δ = 0.

Only considers the largest connected component if the graph is disconnected. Only feasible for small graphs — the brute-force algorithm is O(n^4).

§Examples

use rust_igraph::{Graph, hyperbolicity_twice};

// Tree: δ = 0
let g = Graph::from_edges(&[(0,1),(1,2),(2,3)], false, Some(4)).unwrap();
assert_eq!(hyperbolicity_twice(&g).unwrap(), 0);

// C_4: δ = 1, so 2δ = 2
let g = Graph::from_edges(&[(0,1),(1,2),(2,3),(3,0)], false, Some(4)).unwrap();
assert_eq!(hyperbolicity_twice(&g).unwrap(), 2);