- 2071 Bhadra · 2+4 marks
Dijkstra's shortest paths from source F
Short answer
Dijkstra's algorithm repeatedly selects the vertex with smallest tentative distance, finalizes it, and relaxes outgoing edges. From F, shortest distances: E=1 (F-E), C=3 (F-C), A=7 (F-A), B=9 (F-A-B), D=∞ (unreachable).
Discuss Dijkstra's shortest path algorithm. Find the shortest paths for given graph with source node 'F' using Dijkstra's algorithm. [Figure: directed weighted graph with edges A→B 2, C→A 6, D→B 11, F→A 7, F→C 3, E→C 5, D→F 9, F→E 1]
Dijkstra's algorithm finds the shortest path from a source vertex to all other vertices in a graph with non-negative weights. Keep dist[v] = ∞ for all except the source (0). Repeatedly select the unfinalised vertex u with the smallest dist, finalise it, and relax each outgoing edge (u, v, w): if dist[u] + w < dist[v], set dist[v] = dist[u] + w. Time O(V²) with an array.
Given directed graph
Edges: A→B 2, C→A 6, D→B 11, F→A 7, F→C 3, E→C 5, D→F 9, F→E 1. Source = F.
| Step | Selected | A | B | C | D | E | F |
|---|---|---|---|---|---|---|---|
| Init | - | ∞ | ∞ | ∞ | ∞ | ∞ | 0 |
| 1 | F (0) | 7 | ∞ | 3 | ∞ | 1 | 0 |
| 2 | E (1) | 7 | ∞ | 3 | ∞ | 1 | 0 |
| 3 | C (3) | 7 (3+6 = 9 is worse) | ∞ | 3 | ∞ | 1 | 0 |
| 4 | A (7) | 7 | 9 | 3 | ∞ | 1 | 0 |
| 5 | B (9) | 7 | 9 | 3 | ∞ | 1 | 0 |
| 6 | D (∞) | 7 | 9 | 3 | ∞ | 1 | 0 |
In step 2, E→C gives 1 + 5 = 6, which is not better than 3.
Shortest distances from F:
| Destination | Distance | Path |
|---|---|---|
| E | 1 | F-E |
| C | 3 | F-C |
| A | 7 | F-A |
| B | 9 | F-A-B |
| D | ∞ | no path (D has no incoming edge) |
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Dijkstra's shortest path algorithm · Data Structure and Algorithm, chapter 10 · asked 2×
- Kruskal's MST on 9-vertex graph · Data Structure and Algorithm, chapter 10 · asked 3×
- MST definition; Kruskal's MST on 6-vertex graph · Data Structure and Algorithm, chapter 10
- Kruskal's MST on 7-vertex graph · Data Structure and Algorithm, chapter 10 · asked 3×
- Kruskal's MST on graph A to G · Data Structure and Algorithm, chapter 10 · asked 3×
- Round Robin MST on 7-vertex graph · Data Structure and Algorithm, chapter 10
- Dijkstra shortest path (2074 Bhadra) · Discrete Structure, chapter 4
- Dijkstra shortest path (2072 Asoj) · Discrete Structure, chapter 4
- Dijkstra shortest path (2070 Magh) · Discrete Structure, chapter 4 · asked 4×
- Dijkstra shortest path (2071 Bhadra) · Discrete Structure, chapter 4 · asked 4×