Skip to content

michaeljgoodman/force-directional-graph-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SDL2 Network Graph

Disclaimer: I am completely new to rust. This is likely not very "idiomatic". Be kind

Description

This is a dirty mockup of an engine for displaying network graphs with physics applied to the nodes.

This is largely inspired by the barnes hut model from vis.js, particularly the physics based barnes hut models. I did not implement the barnes hut algorithm in any form, but rather implemented the following physics forces to achieve a similar effect:

  • Central gravity
  • Gravity between nodes
  • Repulsion between nodes
  • Spring tension

Controls

  • Left click and drag nodes to move them
  • Left click and drag the background to pan
  • Use the scroll wheel to zoom and pan
  • Press escape to exit

Requirements

For windows: I've included the SDL2 DLL within the debug and release target folders, but you will need to follow the rest of the associated steps provided in the Rust-SDL2 Readme. In short:

  • Download SDL2-devel-2.x.x-VC.zip
  • Copy the lib files from {extracted}/lib/x64/ to %userprofile%\.rustup\toolchains\{current toolchain}\lib\rustlib\{current toolchain}\lib

For Linux/MacOS: Just follow the simple instructions in the readme

Images

alt text

Click and drag nodes alt text

Todo

  • Implement minimum force, and consider bodies under limit at rest - To remove jitter
  • Implement spatial grid properly, and launch a thread per cell to calculate forces for those circles
  • Only apply forces between close cells - to an extent that we perform minimal calculations, but not to the extent that things float away from eachother (Central gravity should solve this)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages