pub fn delaunay_graph(points: &[Vec<f64>]) -> IgraphResult<Graph>Expand description
Build the Delaunay triangulation graph of a 1D or 2D point set.
points holds one row per point: each inner Vec<f64> is a coordinate
vector of shared dimensionality (inferred from the first row). The
result is an undirected Graph on points.len() vertices whose
edges are exactly the Delaunay-adjacent pairs.
Duplicate points (identical coordinates) are an error — the Delaunay triangulation is undefined for duplicate sites.
§Supported dimensions
- 1D: Points are sorted by coordinate; consecutive points in the
sorted order are connected.
O(n log n). - 2D: Bowyer-Watson incremental insertion.
O(n²)average,O(n²)worst case for pathological inputs. - ≥3D: Currently unsupported; returns
IgraphError::InvalidArgument.
§Errors
IgraphError::InvalidArgumentif the points are zero-dimensional (and there is at least one point), if the rows have inconsistent dimensionality, if any coordinate is NaN or infinite, or if there are duplicate points.IgraphError::InvalidArgumentfor dimensionality ≥ 3 (not yet supported).
§Examples
use rust_igraph::delaunay_graph;
// Three points forming a triangle: all three pairs are connected.
let pts = vec![
vec![0.0, 0.0],
vec![1.0, 0.0],
vec![0.5, 1.0],
];
let g = delaunay_graph(&pts).unwrap();
assert_eq!(g.vcount(), 3);
assert_eq!(g.ecount(), 3);
// 1D: four points on a line.
let pts1d = vec![vec![3.0], vec![1.0], vec![4.0], vec![2.0]];
let g1d = delaunay_graph(&pts1d).unwrap();
assert_eq!(g1d.vcount(), 4);
assert_eq!(g1d.ecount(), 3); // 1-2, 2-3, 3-4 in sorted order