Skip to content

BFS, DFS frames, AdjacencyMatrix and grid generator#3

Merged
dadencukillia merged 10 commits into
mainfrom
algorithm/bfs_dfs
May 3, 2026
Merged

BFS, DFS frames, AdjacencyMatrix and grid generator#3
dadencukillia merged 10 commits into
mainfrom
algorithm/bfs_dfs

Conversation

@dadencukillia

@dadencukillia dadencukillia commented May 3, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

Release Notes

  • New Features

    • Added interactive Breadth-First Search (BFS) visualization with step-through and pause/play controls, including shortest path highlighting
    • Added interactive Depth-First Search (DFS) visualization with frame-based playback and traversal stack visualization
    • Implemented grid graph generation with configurable dimensions and spacing
    • Added matrix operations for graph analysis
  • UI & Visual Improvements

    • New playback control icons (play, pause, forward, back)
    • New node selection indicators (star and flag icons)

@coderabbitai

coderabbitai Bot commented May 3, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 873abd41-994f-4321-b39c-871a3f9af56b

📥 Commits

Reviewing files that changed from the base of the PR and between d1401df and 3ff36f6.

⛔ Files ignored due to path filters (6)
  • src/resources/arrow_back.png is excluded by !**/*.png
  • src/resources/arrow_forward.png is excluded by !**/*.png
  • src/resources/flag_circle.png is excluded by !**/*.png
  • src/resources/pause.png is excluded by !**/*.png
  • src/resources/play.png is excluded by !**/*.png
  • src/resources/star_circle.png is excluded by !**/*.png
📒 Files selected for processing (22)
  • CMakeLists.txt
  • bin/main.cpp
  • include/crocobygraph/graphs.hpp
  • include/crocobygraph/visual.hpp
  • src/interface/adjacency_matrix.cpp
  • src/interface/adjacency_matrix.hpp
  • src/interface/bfs_frame.cpp
  • src/interface/bfs_frame.hpp
  • src/interface/dfs_frame.cpp
  • src/interface/dfs_frame.hpp
  • src/interface/editor_frame.cpp
  • src/interface/grid.cpp
  • src/interface/grid.hpp
  • src/interface/neural_network.hpp
  • src/interface/scene.cpp
  • src/interface/scene.hpp
  • src/internal/resources.cpp
  • src/internal/resources.hpp
  • src/resources/circle_icons.cpp
  • src/resources/circle_icons.hpp
  • src/resources/media_controls_icons.cpp
  • src/resources/media_controls_icons.hpp

📝 Walkthrough

Walkthrough

This PR introduces interactive graph traversal visualization systems for BFS and DFS, with supporting data structures (adjacency matrix representation), icon resources for UI controls, grid generation utility, and integration into the main ECS-based application architecture.

Changes

Graph Traversal Visualization & Infrastructure

Layer / File(s) Summary
Data Structures
src/interface/adjacency_matrix.hpp, src/interface/adjacency_matrix.cpp
Introduces AdjacencyMatrix class: N×N binary matrix stored as std::vector<uint8_t> with copy semantics, transpose(), element-wise OR (operator+), and boolean matrix multiplication (operator*) supporting path analysis.
Graph Topology Extraction
src/interface/scene.hpp, src/interface/scene.cpp
Scene::adjacency_matrix() method extracts directed/undirected edge topology from the scene graph and returns a vector of node entities paired with a constructed AdjacencyMatrix.
Grid Layout Generation
src/interface/grid.hpp, src/interface/grid.cpp
generate_grid(width, height, spacing) creates a 2D node layout with horizontal/vertical adjacency links for grid-based graph visualizations.
BFS Visualization Frame
src/interface/bfs_frame.hpp, src/interface/bfs_frame.cpp
BFSFrame implements step-by-step BFS UI with start/finish node selection, topology change detection, frame-based queue expansion, shortest-path reconstruction, and canvas rendering (visited-order labels and path polyline).
DFS Visualization Frame
src/interface/dfs_frame.hpp, src/interface/dfs_frame.cpp
DFSFrame implements step-by-step DFS UI with start node selection, topology change detection, stack-based traversal with action logging for rewind, and canvas rendering of visited nodes and current stack top.
UI Icon Resources
src/resources/circle_icons.hpp, src/resources/circle_icons.cpp, src/resources/media_controls_icons.hpp, src/resources/media_controls_icons.cpp, src/internal/resources.hpp, src/internal/resources.cpp
Embeds PNG binary data for star/flag circle icons (node selection) and media control icons (play, pause, back, forward) with corresponding Texture2D resource wrappers (StarCircleIcon, FlagCircleIcon, MediaControlIcons) managed by constructor/destructor lifecycle.
Header Integration & Build
include/crocobygraph/graphs.hpp, include/crocobygraph/visual.hpp, CMakeLists.txt
Adds grid.hpp, bfs_frame.hpp, dfs_frame.hpp to public header includes; updates CMake to compile all new source files (adjacency_matrix, bfs_frame, dfs_frame, grid, media_controls_icons, circle_icons).
Application Wiring & Cleanup
bin/main.cpp, src/interface/editor_frame.cpp, src/interface/neural_network.hpp
main() simplified to register DFSFrame and EditorFrame (replacing PhysicsFrame); removed unused <optional> include from editor_frame.cpp; removed inline specifier from neural_network template.

Sequence Diagram

sequenceDiagram
    participant User
    participant BFSFrame
    participant Scene
    participant AdjacencyMatrix
    participant Canvas

    User->>BFSFrame: select_start_node(entity)
    User->>BFSFrame: select_finish_node(entity)
    BFSFrame->>Scene: adjacency_matrix()
    Scene->>AdjacencyMatrix: construct from edge topology
    AdjacencyMatrix-->>Scene: matrix built
    Scene-->>BFSFrame: (node_list, matrix)
    
    Note over BFSFrame: Topology Valid
    User->>BFSFrame: play/pause/seek frame
    
    loop For each frame increment
        BFSFrame->>AdjacencyMatrix: check neighbors of queue front
        BFSFrame->>BFSFrame: expand queue, update visited_order
        alt finish_node found
            BFSFrame->>AdjacencyMatrix: build_nodes_path() via transpose
            BFSFrame->>BFSFrame: store shortest path
        end
    end
    
    BFSFrame->>Canvas: draw visited_order labels
    BFSFrame->>Canvas: draw shortest_path polyline
    Canvas-->>User: visualized traversal
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 Hop through graphs with BFS flair,
DFS stacks with frames to spare,
Matrices transpose and multiply fast,
Grid nodes linked from first to last,
Icons gleam as the search runs bright!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)

✅ Unit Test PR creation complete.

  • Create PR with unit tests
  • Commit unit tests in branch algorithm/bfs_dfs

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@dadencukillia dadencukillia merged commit 964da01 into main May 3, 2026
2 of 3 checks passed
@dadencukillia dadencukillia deleted the algorithm/bfs_dfs branch May 3, 2026 16:52
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

✅ Created PR with unit tests: #4

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