Skip to content

Tree based algorithms and DS#9

Merged
TamimEhsan merged 9 commits into
masterfrom
tree-base
Jun 12, 2026
Merged

Tree based algorithms and DS#9
TamimEhsan merged 9 commits into
masterfrom
tree-base

Conversation

@TamimEhsan

Copy link
Copy Markdown
Owner

This PR adds a tree interface for the library and adds a new segment BST and refactors old segment recursion tree.

New /connectivity route on the shared graph workspace:
- Connected Components (undirected, BFS flood-fill), and for directed
  graphs Strongly Connected (Tarjan, low-link labels) + Weakly Connected.
- Algorithm dropdown adapts to the Directed toggle (CC when undirected,
  SCC/WCC when directed); resets cleanly when the option set changes.

Adds the reusable `colorNode` action (arbitrary node color) to the shared
editor + node, used to tint each component. Added the home card.
…cates

- When both A->B and B->A exist, offset each edge to its own side
  (parallel) so the two arrows and weight labels no longer overlap;
  detected reactively via useStore.
- Toggling to Undirected now drops reverse-duplicate edges (one per
  unordered pair) so a single line + weight is shown.
New /network-flow route on the shared workspace: directed capacity graph
with source (S) and sink (F). Edmonds-Karp (BFS) and Ford-Fulkerson (DFS)
animate augmenting paths, edges show flow/capacity, and the run ends with
a min-cut highlight (source-side tint + cut edges).

Shared additions: useGraphEditor gains an initialDirected option,
source/sink seeding from presets, and a setFlow action; floating-edge
shows "flow / capacity" during a run (capacity still inline-editable).
Add the Connectivity (components / SCC / WCC) and Network Flow
(Edmonds-Karp / Ford-Fulkerson, max flow / min cut) visualizers to the
segment lists and algorithm breakdown.
New src/components/tree/: a logical-tree editor (use-tree-editor) with an
action-log executor, an SVG canvas that auto-lays-out the tree (binaryLayout,
preserving left/right) and tweens node positions + the viewBox on one shared
clock so edges stay attached and everything reflows together, plus
tree-node / tree-edge / tree-menu.

First consumer: /bst — insert / delete / search with animated restructuring
(bst.js immutable, id-preserving ops + action planners). Added the home card.
Move the Buchheim tidy-tree layout into components/tree/layout.js
(buchheimLayout) and express the recursion-tree builders as logical trees
plus a recursionActions planner that reveals a fixed, pre-laid-out tree via
the action log (setTree hidden, then markNode / setLabel as the DFS walks).
Each node shows its call label with "= <result>" revealed on return.

The page is now thin (useTreeEditor + TreeCanvas + its menu); use-tree-editor
gains a hidden flag on setTree, and tree-node shrinks longer labels to fit.
Deletes the bespoke canvasSVG / vertex / edge / Tree.js.
@TamimEhsan TamimEhsan merged commit 96d3d3e into master Jun 12, 2026
1 check 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