Skip to main content

layout_sphere

Function layout_sphere 

Source
pub fn layout_sphere(graph: &Graph) -> Vec<(f64, f64, f64)>
Expand description

Place vertices approximately uniformly on a unit sphere.

Uses the Saff-Kuijlaars spiral algorithm (Mathematical Intelligencer 19.1, 1997).

ยงExamples

use rust_igraph::{Graph, layout_sphere};

let g = Graph::with_vertices(10);
let coords = layout_sphere(&g);
assert_eq!(coords.len(), 10);
// All points are approximately on the unit sphere
for &(x, y, z) in &coords {
    let r = (x * x + y * y + z * z).sqrt();
    assert!((r - 1.0).abs() < 0.01);
}