Skip to content

Graph Algorithms#7

Merged
TamimEhsan merged 10 commits into
masterfrom
graph
Jun 11, 2026
Merged

Graph Algorithms#7
TamimEhsan merged 10 commits into
masterfrom
graph

Conversation

@TamimEhsan

Copy link
Copy Markdown
Owner

This PR adds a new interface for creating interactive edge and node based graph.

Using the interface it also adds 3 new segment

  • Graph Traversal (BFS, DFS)
  • Shortest Path (Djikstra, Bellman-Ford)
  • Minimum Spanning Tree (Kruskal, Prim)

New /graph route built on React Flow: a hand-positioned starter graph
that users can edit with keyboard controls (N add node, E add edge,
S/F set start/finish, Del delete, drag to move) and run BFS or DFS over.

- Pure planners (bfsActions/dfsActions) return a flat action log; the
  page is a generic executor applying each step with a delay
- Directed/undirected toggle; finish node stops the run and highlights
  the start->finish path
- Floating edges (no handles) with a big mid-edge arrow showing travel
  direction, for both directed and undirected graphs
- Added home card linking to /graph
Add a Data Structures section covering the Linked List and interactive
Graph Traversal visualizers, refresh the README segment list, and note
both additions in the timeline.
…Ford)

New /shortest-path route reusing the /graph editor with weighted edges
and per-node distance labels.

- Pure planners (dijkstraActions / bellmanFordActions) emit the action
  log; Bellman-Ford runs V-1 passes plus a detection pass that flags a
  negative cycle. Dijkstra warns on negative edges.
- Inline-editable edge weights (click a weight to type a new value),
  wired through a new EdgeWeightContext.
- Additive enhancements to the shared graph components: distance badge
  on the node, weight label + relax/negcycle edge states on the edge;
  /graph BFS/DFS is unchanged.
- Weight label anchors to the stable edge orientation so it doesn't
  jump sides during traversal.
- Added home card linking to /shortest-path.
Pull the shared React Flow editor + action-log executor out of the two
graph pages so future graph visualizers can reuse it:

- use-graph-editor: hook owning graph state, the keyboard editor, and an
  algorithm-agnostic executor (run(actions) / getContext()); a `weighted`
  option gates edge weights + inline editing.
- graph-canvas: React Flow canvas + mode/status overlays + EdgeWeightContext.
- graph-menu: shared configurable sidebar.
- graph-node / floating-edge: moved here from app/graph.
- graph.js toFlow unified (weight optional); shortestPath.js reuses it.
Rewrite the page as thin config (useGraphEditor + GraphCanvas +
GraphMenu) and remove its per-page menu; BFS/DFS dispatch is the only
page-specific logic left.
Rewrite as thin config (useGraphEditor with weighted + GraphCanvas +
GraphMenu) and remove its per-page menu; Dijkstra/Bellman-Ford dispatch
is the only page-specific logic left.
- Move weightedAdjacency/edgeList into graph.js as core helpers
  (shortestPath.js re-exports them; its imports are unchanged).
- floating-edge: draw the mid-edge travel arrow only when a direction
  is set (travelTo), so undirected uses get no arrow; add a 'reject'
  edge color.
- graph-menu: add a hideDirected prop to omit the Directed toggle.
New /mst route on the weighted graph workspace (undirected, hideDirected
menu). kruskalActions uses Union-Find — edges accept green in weight
order, cycle edges fade, running total in the status line; primActions
grows the tree from the S start node. Both report a not-connected forest.

Added the home card and a real shortest-path thumbnail.
- Selection highlight: clicked node gets a sky-blue ring (stacked outside
  the start/finish ring); clicked edge turns sky-blue and thicker.
- Modal keyboard editing: N add-node, E add-edge (chain through clicked
  nodes), D delete — all persistent until Esc. On a selected node: S/F/Del;
  on a selected edge: X reverse (directed) / Del. Disabled React Flow's
  built-in delete key so deletion goes through one path.
- On-canvas command bar is now context-sensitive: shows the available
  options for the current mode or the selected node/edge.
- Menu controls rendered as <kbd> keycaps; per-element actions collapsed to
  a single "click a Node / Edge for options" pointer to the command bar.
- Shared Key component (kbd.jsx).
Add the Shortest Path (Dijkstra / Bellman-Ford) and Minimum Spanning
Tree (Kruskal / Prim) visualizers to the segment lists and algorithm
breakdown; group the interactive graph visualizers in the About page.
@TamimEhsan TamimEhsan merged commit 4c67a02 into master Jun 11, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant