You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project implements **Dijkstra's Algorithm** for finding the shortest path in a weighted graph. Dijkstra's Algorithm is a classic solution in computer science for solving the single-source shortest path problem, where the goal is to determine the minimum distance from a starting node to all other nodes in a graph with non-negative edge weights.
6
+
7
+
## Features
8
+
9
+
-**Graph Representation:** Supports both adjacency list and adjacency matrix representations.
10
+
-**Customizable Input:** Users can define their own graphs and specify the source node.
11
+
-**Efficient Implementation:** Utilizes a priority queue (min-heap) for optimal performance.
12
+
-**Path Reconstruction:** Returns both the shortest distances and the actual paths taken.
13
+
-**Error Handling:** Handles disconnected graphs and invalid input gracefully.
14
+
15
+
## How It Works
16
+
17
+
1.**Initialization:**
18
+
All node distances are set to infinity except the source node, which is set to zero.
19
+
20
+
2.**Processing:**
21
+
The algorithm repeatedly selects the node with the smallest known distance, updates the distances to its neighbors, and continues until all nodes have been processed.
22
+
23
+
3.**Result:**
24
+
The shortest path from the source to every other node is computed and can be retrieved.
0 commit comments