use scirs2_core::ndarray::array;
use scirs2_spatial::voronoi::Voronoi;
#[allow(dead_code)]
fn main() {
let points = array![[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0], [0.5, 0.5]];
println!("Computing Voronoi diagram for {} points", points.nrows());
let vor = match Voronoi::new(&points.view(), false) {
Ok(v) => v,
Err(e) => {
println!("Error computing Voronoi diagram: {e}");
return;
}
};
println!("\nVoronoi vertices:");
let vertices = vor.vertices();
for i in 0..vertices.nrows() {
println!(" Vertex {}: {:?}", i, vertices.row(i));
}
println!("\nVoronoi regions:");
let regions = vor.regions();
for (i, region) in regions.iter().enumerate() {
println!(" Region {i}: {region:?}");
}
println!("\nPoint to region mapping:");
let point_region = vor.point_region();
for i in 0..point_region.len() {
println!(" Point {} -> Region {}", i, point_region[i]);
}
println!("\nVoronoi ridges:");
let ridge_points = vor.ridgepoints();
let ridge_vertices = vor.ridge_vertices();
for i in 0..ridge_points.len() {
println!(
" Ridge {}: Between points {:?}, Vertices: {:?}",
i, ridge_points[i], ridge_vertices[i]
);
}
println!("\nComputing furthest-site Voronoi diagram");
let furthest_vor = match Voronoi::new(&points.view(), true) {
Ok(v) => v,
Err(e) => {
println!("Error computing furthest-site Voronoi diagram: {e}");
return;
}
};
println!("\nFurthest-site Voronoi vertices:");
let furthest_vertices = furthest_vor.vertices();
for i in 0..furthest_vertices.nrows() {
println!(" Vertex {}: {:?}", i, furthest_vertices.row(i));
}
}