The layout module implements force-directed graph layout using a custom Fruchterman-Reingold algorithm.
pub struct ForceLayout {
positions: HashMap<usize, Vec3>,
velocities: HashMap<usize, Vec3>,
}Creates an empty force layout.
Creates a force layout initialized with the standard pipeline nodes arranged in a circle.
Runs one iteration of the force-directed layout algorithm, updating node positions based on:
- Repulsion between all nodes
- Attraction along edges
- Center gravity to keep the graph bounded
Returns the 3D position of a node by index.
Returns all node positions.
See Graph for node creation and Iso for projection details.
let mut layout = ForceLayout::for_pipeline();
for _ in 0..100 {
layout.tick();
}
for (idx, pos) in layout.all_positions() {
println!("Node {}: {:?}", idx, pos);
}