0 3

BIT152 · 0 · 10 marks

What is shortest path finding problem? Use Dijkstra's algorithm to find the length of the shortest path between a and z in the given weighted graphs.

What is shortest path finding problem? Use Dijkstra's algorithm to find the length of the shortest path between a and z in the given weighted graphs.[10]

Discrete StructureChapter 9: Trees and Graph AlgorithmsDijkstra's algorithm for shortest pathsNumerical: Dijkstra's shortest path

Shortest Path Finding Problem and Dijkstra's Algorithm

Given

  • Algorithm required: Dijkstra's algorithm
  • Source vertex: $a$
  • Destination vertex: $z$
  • Graph: "the given weighted graph" - the actual graph image/edge weights are NOT provided in the question text.

Missing data: The specific weighted graph (vertices, edges, and edge weights) is not reproduced in the question. Without it, an exact numeric shortest-path length cannot be computed uniquely.

Because the graph is missing, I will (a) explain the problem and algorithm fully, and (b) demonstrate the method on a representative standard graph, clearly flagged as an assumption. The numeric answer below is valid only for that assumed graph.


Solution

What is the Shortest Path Finding Problem?

The shortest path problem is the task of finding a path between two vertices in a weighted graph $G = (V, E)$ such that the sum of the edge weights along the path is minimum.

  • Weights represent cost, distance, or time.
  • Graph may be directed or undirected, but Dijkstra requires non-negative weights.
  • Variants: single-pair, single-source (one source to all), all-pairs.
  • Applications: GPS routing, network routing protocols (OSPF), telecommunication, robotics.

Dijkstra's Algorithm (greedy)

  1. $d[a] = 0$, $d[v] = \infty$ for all other $v$; all vertices unvisited.
  2. Pick the unvisited vertex $u$ with minimum $d[u]$.
  3. Relax each unvisited neighbour $w$: if $d[u] + w(u,w) < d[w]$, set $d[w] = d[u] + w(u,w)$.
  4. Mark $u$ visited.
  5. Repeat until $z$ is finalized.

Worked Example (assumed standard graph: graph not given in question)

Edges: $a\text{-}b=2,\ a\text{-}d=4,\ a\text{-}e=7,\ b\text{-}c=3,\ b\text{-}e=3,\ c\text{-}f=5,\ c\text{-}z=3,\ d\text{-}e=3,\ e\text{-}f=2,\ f\text{-}z=4$

IterCurrentabcdefz
Init-0∞∞∞∞∞∞
1a (0)0✓2∞47∞∞
2b (2)0✓2✓545∞∞
3d (4)2✓54✓5∞∞
4c (5)5✓4✓5108
5e (5)5✓5✓78
6f (7)7✓min(8, 7+4=11)=8
7z (8)8✓

Relaxation details:

  • From $c$: $z = 5+3 = 8$, $f = 5+5 = 10$.
  • From $e$: $f = 5+2 = 7 < 10 \Rightarrow f = 7$.
  • From $f$: $z = 7+4 = 11 > 8 \Rightarrow$ no update.

Result (for the assumed graph)

$$d[z] = 8$$

Shortest path: $a \to b \to c \to z$ with length $2 + 3 + 3 = 8$.

Note: This numeric answer depends entirely on the assumed edge set. For the actual exam graph, apply the same procedure to the given weights.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.