Crate forceatlas2

Crate forceatlas2 

Source
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 rng = rand::thread_rng();
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)],
	&mut rng,
);
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.

Modules§

forces
Traits and implementations about the forces used in the layout.
trees
Quad-tree and Oct-tree implementations.

Structs§

AbstractNode
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§

BuildableNodes
Collection of nodes that can be built node by node
Edges
Collection of edges for the layout
Nodes
Collection of nodes for the layout

Functions§

sample_unit_cube
Uniform random distribution of points in an (N-1)-cube

Type Aliases§

EdgeBTreeMap
Collection of edges for the layout, stored in a BTreeMap
EdgeHashMap
Collection of edges for the layout, stored in a HashMap
EdgeVec
Collection of edges for the layout, stored in a Vec
NodeHashMap
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