Skip to content

Force directed graph drawing using WEBGL, WebAssembly and Emscripten. Created purely to avoid studying for exams.

Notifications You must be signed in to change notification settings

yatsukha/force-directed-graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Force directed graph drawing

Implementation of graph drawing using force directed algorithm, specifically the Fruchterman-Reingold variant.

See it action here.

Examples

In GIFs below the algorithm was purposefully slowed down so the changes can be observed.

Responding to addition of vertices and connections:

00

Untagling of a trivial structure:

01

Responding to deletion of connections:

02

Details

The algorithm was written in C++ and then compiled into WebAssembly using emsdk so that it can be used in JavaScript. The graph was displayed using WEBGL (3.0 es) in a canvas on a website. The website has several graph manipulation functionalities (add, connect, disconnect, etc.) and a slider for controlling algorithm speed.

website

Building

Requirements:

To build the project and output the required wasm binary in the correct folder, run the following command in the root folder:

$ em++ WASM=1 graph.cpp -std=c++17 -g --bind -s -o out/main.js

There is also a VSCode task in the repository that can be used to build. Keep in mind that emsdk binaries need to be in the path (see link above on how to do that).

Running

To run the website, first build the project, and then run any http server and set out as the root folder for static content. After that just connect to localhost:8080/main.html or some other port you have defined.

Example that uses the darkhttpd tiny webserver (from root folder of project):

$ darkhttpd out

About

Force directed graph drawing using WEBGL, WebAssembly and Emscripten. Created purely to avoid studying for exams.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published