Question: * * Problem Statement: * * Write a Python program that implements Dijkstra's Algorithm to find the shortest path in a weighted, directed graph. The

**Problem Statement:**
Write a Python program that implements Dijkstra's Algorithm to find the shortest path in a weighted, directed graph. The program should take as input the following:
1. The number of vertices in the graph.
2. A list of edges in the format (source, destination, weight).
3. The starting vertex from which the shortest path should be calculated.
The program should output:
- The shortest path from the starting vertex to all other vertices.
- The corresponding distance for each path.
Constraints:
- The graph is represented using an adjacency matrix.
- The graph does not contain negative weight edges.
- Assume the graph is connected, i.e., every vertex is reachable from the start vertex.
Input Example:
```
Number of vertices: 5
Edges: [(0,1,10),(0,3,5),(1,2,1),(3,1,3),(3,2,9),(3,4,2),(4,2,6)]
Starting vertex: 0
```
Expected Output:
```
Vertex Distance from Source
00
18
29
35
47
```

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!