Expand description
Implementation of ForceAtlas2 – force-directed Continuous Graph Layout Algorithm for Handy Network Visualization (i.e. position the nodes of a n-dimension graph for drawing it more human-readably)
This example creates a graph containing 4 nodes indexed from 0 to 3, linked by undirected weighted edges.
let mut layout = forceatlas2::Layout::<f32, 2>::from_abstract(
forceatlas2::Settings::default(),
(0..4).map(|i| (i, forceatlas2::AbstractNode::default())),
vec![
((0, 1), 1.0),
((1, 2), 1.5),
((0, 2), 0.7),
((2, 3), 1.0),
],
);
for _ in 0..100 {
layout.iteration();
}
for node in layout.nodes.iter() {
println!("({}, {})", node.pos.x(), node.pos.y());
}
Layout
supports multiple collection types for nodes and edges.
Structs§
- Abstract
Node - Graph vertex without position nor speed
- Layout
- Graph spatialization layout
- Node
- Graph vertex positioned in the layout
- Settings
- Settings for the graph layout
- VecN
- N-dimensional vector
Traits§
- Buildable
Nodes - Collection of nodes that can be built node by node
- Edges
- Collection of edges for the layout
- Nodes
- Collection of nodes for the layout
Type Aliases§
- EdgeB
Tree Map - Collection of edges for the layout, stored in a BTreeMap
- Edge
Hash Map - Collection of edges for the layout, stored in a HashMap
- EdgeVec
- Collection of edges for the layout, stored in a Vec
- Node
Hash Map - Collection of nodes for the layout, stored in a HashMap
- NodeVec
- Collection of nodes for the layout, stored in a Vec
- Vec2
- 2D vector
- Vec3
- 3D vector
Trait Aliases§
- Coord
- Some traits that are convenient for coordinates