Skip to main content

Crate fa2

Crate fa2 

Source
Expand description

The fa2 crate provide a Rust implementation of the ForceAtlas2 graph layout algorithm.

Jacomy M, Venturini T, Heymann S, Bastian M (2014) ForceAtlas2, a Continuous Graph Layout Algorithm for Handy Network Visualization Designed for the Gephi Software. PLoS ONE 9(6): e98679. https://doi.org/10.1371/journal.pone.0098679

This implementation is generic over its float precision so you can run it with f32 or f64.

Running the algorithm

// First you need to populate the graph data on which the algorithm will run:
let mut data = FA2Data::<f32>::new();

// Then you need to instantiate settings
let settings = FA2Settings::default();

// Then you can build the layout runner
let layout = settings.build(data);

// Running a fixed number of iterations
layout.run(100);

// Retrieving positions
layout.data().positions()

For a command line tool able to run this implementation of the algorithm and/or to read a real-life example, check out the run example of this crate.

Structsยง

FA2Data
A struct holding the data necessary to represent a graph that will be spatialized by the FA2 algorithm.
FA2Layout
The struct responsible for actually running the iterations of the FA2 algorithm.
FA2Settings
Struct representing a settings of the FA2 layout algorithm.