Fdg Save

A Force Directed Graph Framework for Rust.

Project README

fdg

A (force-directed) graph drawing library for Rust. Convert any petgraph::Graph into a pretty picture!

screenshot

The goal of this library is to create some idiomatic building blocks for writing fast graph drawing algorithms in Rust. I hope to implement more algorithms such as ForceAtlas2 (2014) and Kamada-Kawai (1989). I also want to experiment with generating the layouts with SIMD, parallelization, and GPU compute.

The library is currently undergoing a complete rewrite with more performant algorithms and a more generic API (now supports computing in N dimensions 😉). The pre 1.0 version is now located in the old branch.

Contributions always welcome!

Usage

use fdg::{fruchterman_reingold::FruchtermanReingold, Force, ForceGraph};

// your dataset: Into<StableGraph<(), ()>>

// Initialize a ForceGraph in 2 dimentions with random node positions from -10.0..=10.0.
let mut graph: ForceGraph<f32, 2, (), ()> = fdg::init_force_graph_uniform(dataset, 10.0);

// Apply the Fruchterman-Reingold (1991) force-directed drawing algorithm 100 times.
FruchtermanReingold::default().apply_many(&mut graph, 100);
// Center the graph's average around (0,0).
Center::default().apply(&mut graph);

// Render nodes:
println!("nodes:");
for (_, pos) in graph.node_weights() {
    println!("{pos:?}");
}

// Render edges:
println!("edges:");
for edge_idx in graph.edge_indices() {
    let (source_idx, target_idx) = graph.edge_endpoints(edge_idx).unwrap();

    println!("{edge_idx:?}: {:?} to {:?}", &graph[source_idx].1, &graph[target_idx].1);
}

See basic.rs...

Open Source Agenda is not affiliated with "Fdg" Project. README Source: grantshandy/fdg

Open Source Agenda Badge

Open Source Agenda Rating