Graph Visualizer is a browser-based tool for visualizing directed and undirected graphs, featuring interactive traversal algorithms using WebGL and Emscripten. Try it out with the demo (note: might not scale well on mobile devices).
BFS - Traverses the graph using a queue, exploring all neighbors of a node before moving to the next level.
DFS - Traverses the graph using a stack, exploring as far as possible along each branch before backtracking.
Dijkstra - Finds the shortest path from a source node to all other nodes using a priority queue, ensuring the lowest-cost path is always processed first. Recovers the best path by backtracking from the target node to the source.
A* - An optimized shortest-path algorithm that combines Dijkstra’s approach with a heuristic function to estimate the remaining cost, guiding the search more efficiently toward the target.
Bellman-Ford - Computes the shortest paths from a source node to all other nodes, allowing for negative-weight edges. Iteratively relaxes edges, ensuring that no shorter path exists. Can detect negative-weight cycles.
The project uses the web-ui frontend framework for rendering. It follows the Model-View-Controller (MVC) architecture to separate concerns effectively.
Model - Abstract elements of the Graph Visualizer such as graph nodes, their physical properties along with graph algorithms, state of individual nodes and representation.
View - Graphical aspect of both the program's state, UI and the graph itself.
Controller - Interaction with the canvas with mouse and canvas translation to model component, and canvas resizing (no keyboard integration at this point).
Graph Visualizer includes a force-directed graph simulation that models realistic physical interactions between nodes. The simulation applies several forces to create a natural graph layout:
Repulsion Force – Nodes repel each other to avoid overlap, using a repulsion constant k_r.
Attraction Force – Connected nodes attract each other like springs, controlled by an attraction constant k_a and a rest length parameter.
Gravity Force – Nodes experience a gravitational pull toward a central point, determined by a gravity constant k_g.
Velocity and Damping – The simulation updates node positions and velocities over time time_step, with damping to smooth movements.
Explosion Force – An optional burst force can be applied to disperse nodes outward, simulating an explosion effect.
These physics-based forces create an intuitive and interactive experience when exploring graph structures.