pub fn pseudo_diameter(
graph: &Graph,
start: Option<VertexId>,
directed: bool,
unconn: bool,
) -> IgraphResult<PseudoDiameterResult>Expand description
Approximate the diameter of a graph using pseudo-peripheral vertex search.
Starting from start, repeatedly finds the most distant vertex and
switches to it until the eccentricity no longer increases. The result
is a lower bound on the true diameter.
For disconnected graphs, if unconn is true, returns the diameter of
the component containing start; if false, returns f64::INFINITY.
§Arguments
graph— input graphstart— starting vertex (ifNone, uses vertex 0)directed— whether to respect edge directions (ignored for undirected graphs)unconn— what to do if graph is disconnected
§Errors
Returns an error if start is out of range.
§Examples
use rust_igraph::{Graph, pseudo_diameter};
// Path 0-1-2-3-4: diameter is 4
let mut g = Graph::with_vertices(5);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
g.add_edge(3, 4).unwrap();
let result = pseudo_diameter(&g, Some(0), false, true).unwrap();
assert_eq!(result.diameter, 4.0);