Tree based algorithms and DS#9
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a tree interface for the library and adds a new segment BST and refactors old segment recursion tree.