Skip to main content

Frontend Architecture

Technology Stack

LayerTechnologyVersion
FrameworkReact19
Build toolVite + SWC7.x
CSS utilityUnoCSS66.x
Graph rendererReagraph (Three.js/WebGL)4.30
WASM runtimewasm-bindgen0.2
Package managerpnpmlatest

Layout

The UI is a full-screen split layout with no document scroll:

  • Left 2/3 — Graph visualization canvas (Reagraph WebGL). Shows an interactive 2D or 3D graph. The canvas fills its container absolutely, and overflow: hidden is enforced from html down to prevent scroll.
  • Right 1/3 — Control panel with internal scroll. Contains file upload, format and algorithm selection, node inputs, run button, and results panel.

Graph Rendering

Reagraph renders the graph using Three.js with WebGL — node/edge rendering is GPU-accelerated. Up to 3,000 nodes are displayed simultaneously. The renderer supports five layout algorithms:

LayoutTypeBest For
Force 2DforceDirected2dGeneral graphs
Force 3DforceDirected3dDense graphs with depth
Circularcircular2dOrdered sequences
Radial 2DradialOut2dTrees, hierarchies
Radial 3DradialOut3dDeep hierarchies

Step Animation

Algorithm results are animated step-by-step. An animStep counter increments on a configurable timer:

SpeedInterval
Fast40ms
Medium100ms
Slow280ms

At each tick, visiblePathNodes is computed as the first animStep nodes of the path array. WASM recomputes node styles with this subset, so nodes "light up" progressively.

For Kruskal's MST, the path array is interleaved [u0, v0, u1, v1, ...] pairs — animation reveals one edge pair per step.

Hover Neighbor Highlighting

Hovering a node triggers onNodePointerOver, setting hoverNodeId. The actives prop passed to Reagraph is then [hoverNodeId, ...neighbors] where neighbors come from parsedGraph.neighborMap[hoverNodeId] — a plain array lookup, no Map construction at hover time. All other nodes are dimmed with inactiveOpacity: 0.07.

A search input accepts a node ID string. On submit:

  1. Checks parsedGraph.nodes for existence
  2. Calls graphRef.current.centerGraph([id]) to move the camera to that node
  3. Shows the selected node's degree and optional shortest-path distance in an info panel

Graph Metrics Panel

The /graph_metrics endpoint is called on demand. Results displayed:

  • Node and edge counts
  • Graph density (E / N(N−1))
  • Connected component count
  • DAG status
  • Average out-degree
  • Top 5 hub nodes by degree

Results Display

Each algorithm type has a dedicated result renderer:

AlgorithmDisplay
BFS / DFSNumber of nodes visited
Dijkstra / Bellman-FordDistance table; click node to see distance
A*Path node count
Bellman-Ford (negative cycle)Warning banner
Kruskal MSTMST edge count; green-highlighted edges
PageRankHorizontal bar chart of top 15 nodes
SCCColor-coded component list sorted by size
Topological SortOrdered node list (first 50 shown)

Component Architecture

App.tsx
├── uploads file via FileReader
├── posts to Web Worker → receives ParsedGraph
└── passes parsedGraph to GraphView

GraphView.tsx
├── useMemo: WASM build_path_sets → pathNodeSet, pathEdgeSet, mstEdgeSet
├── useMemo: WASM compute_node_styles → graphNodes[] for Reagraph
├── useMemo: WASM compute_edge_styles → graphEdges[] for Reagraph
├── useEffect: animation timer (animStep++)
└── GraphCanvas (Reagraph) → renders WebGL scene