Skip to content

feat(pathfinding): Add Bidirectional BFS Algorithm #83

Description

@Sanan507

Overview

Implement Bidirectional BFS in the pathfinding engine. It simultaneously expands two frontiers — one from the source node and one from the target node — meeting in the middle to halve search depth and explore significantly fewer nodes.

Implementation Details & File Reference

  • Algorithm Model: Create backend/src/main/java/com/algorithmrace/visualizer/algorithms/pathfinding/BidirectionalBFSModel.java extending PathfindingModel.
    • Maintain forward queue (start) and backward queue (end), alternating step expansions.
    • Record visited cells with distinct CellState values (VISITED_FORWARD, VISITED_BACKWARD) for visual distinction.
    • Join parent chains when frontiers intersect to reconstruct the complete path.
  • Factory Registration: Register "Bidirectional BFS" in PathfindingFactory.java.
  • Complexity Catalog: Add entry with O(b^(d/2)) time note in ComplexityCatalog.java.
  • Frontend Metadata: Add entry in frontend/src/data/algorithmMetadata.ts.

Definition of Done

  • Bidirectional BFS appears in the Pathfinding Arena.
  • Grid visualization displays two expanding frontiers converging in the middle.
  • Metrics accurately display total cells visited and optimal path length.

Skill Level

Medium — requires dual-frontier state management and path stitching at intersection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions