| Crates.io | grapher |
| lib.rs | grapher |
| version | 0.2.2 |
| created_at | 2024-09-08 10:40:09.752463+00 |
| updated_at | 2024-09-14 16:44:28.626632+00 |
| description | Simulate and visualize a force directed graph |
| homepage | |
| repository | https://github.com/iceHtwoO/RustGrapher |
| max_upload_size | |
| id | 1367978 |
| size | 21,657,163 |
A library to simulate and visualize a 2D force directed graph in rust.

Barnes-Hut is a approximation algorithm for n-body simulation.
The force directed graph calculates for each node the repulsive force to other nodes which will lead to a complexity of $O(n^2)$.
Using a k-d Tree(Quadtree) the Barnes-Hut algorithm groups far away nodes and only calculates the repulsive force once.This results in a complexity of $O(nlogn)$.
[!TIP] Run the project with
--releasefor the best performance(~10x).
On a Ryzen 7 3700X the library can calculate 2000 simulation steps per second at 1000 Nodes. (Using 16 Physics threads)
return - Centers the camera on the average poisson of all nodes.space - Start/Pause simulationscroll wheel - Zoom in or outW, A, S and D - to move the cameraClick and drag - move nodesP - switch from drag to node place(only works while simulation is paused) // Build a PetGraph
let mut rng = rand::thread_rng();
let graph: petgraph::Graph<(), (), Directed> =
petgraph_gen::barabasi_albert_graph(&mut rng, 1000, 1, None);
// Configure the simulator
let simulator = SimulatorBuilder::new()
.delta_time(0.01)
.freeze_threshold(-1.0)
.build(graph.into());
// Start the renderer
let renderer = Renderer::new(simulator);
renderer.create_window();