A very simple, arbitrarily dimensional, force-directed graph implementation in Rust.
This implementation is an exercise in the use of the ndarray crate.
The well known force-directed graph algorithm used here is known to work well for up to a hundred or so nodes. Other more complex algorithms scale to larger graphs.
You could get a constant-time speedup
by avoiding the luxurious number of ndarray
allocations
used in this code,
favoring instead re-use of arrays
and in-place operations.
A Rust development environment is required, e.g., as installed by rustup.
The cargo-make tool
is used to coordinate the example web application,
and the trunk tool is used by cargo-make
.
The glayout.rs sources contain the platform-independent graph layout code, but this repo isn't set up to build a proper library right now.
An example showing the layout working
can be run via cargo make example
after installing the dependencies listed above.
(This repo is also an exercise in Web Assembly and JavaScript integration.)
The most simple workflow is to hit the "New Graph" button and then hit the iterate button to see the algorithm changing the layout.
You will probably need to zoom out. You can pan the viewpoint and zoom using a scrollwheel or two fingers on a trackpad, as usual for graphosaurus WebGL 3D graph displays.