Skip to content

feat: add Dijkstra's Algorithm using Adjacency Matrix - #3201

Open
binarymind-dev wants to merge 1 commit into
TheAlgorithms:masterfrom
binarymind-dev:patch-2
Open

feat: add Dijkstra's Algorithm using Adjacency Matrix#3201
binarymind-dev wants to merge 1 commit into
TheAlgorithms:masterfrom
binarymind-dev:patch-2

Conversation

@binarymind-dev

Copy link
Copy Markdown

Description

This PR adds an implementation of Dijkstra's Shortest Path Algorithm
using an Adjacency Matrix representation, without a priority queue.

Changes

  • Added graph/dijkstra_adjacency_matrix.cpp
  • Computes shortest distances from a single source to all vertices in O(V^2)
  • Handles disconnected graphs (unreachable vertices marked with INT_MAX)
  • Includes self-test with assert statements

Difference from existing implementations

  • dijkstra.cpp uses an adjacency list + priority queue (better for sparse graphs)
  • bidirectional_dijkstra.cpp runs a bidirectional search from both source and target
  • This implementation uses an adjacency matrix + linear scan (simpler, better
    for dense graphs, no heap overhead)

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the stale Author has not responded to the comments for over 2 weeks label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Author has not responded to the comments for over 2 weeks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant