Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
14 views3 pages

Exercise 9

The document outlines the application of Bellman's algorithm to find the shortest path from an origin to a destination through various towns, resulting in two possible shortest paths with a total weight of 80. It also describes the use of Kruskal's algorithm to construct a minimum spanning tree for connecting neighborhoods in Riyadh, detailing the iterative process of connecting nodes with the least total length. The algorithms ensure efficient routing and cost-effective cable laying in the respective scenarios.

Uploaded by

rraaffeeeeff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

Exercise 9

The document outlines the application of Bellman's algorithm to find the shortest path from an origin to a destination through various towns, resulting in two possible shortest paths with a total weight of 80. It also describes the use of Kruskal's algorithm to construct a minimum spanning tree for connecting neighborhoods in Riyadh, detailing the iterative process of connecting nodes with the least total length. The algorithms ensure efficient routing and cost-effective cable laying in the respective scenarios.

Uploaded by

rraaffeeeeff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Network

Q.1: You need to take a trip by car to another town that you have never visited before.
Therefore, you are studying a map to determine the shortest route to your destination.
Depending on which route you choose, there are five other towns (call them A, B, C, D, E)
that you might pass through on the way. The map shows the mileage along each road that
directly connects two towns without any intervening towns.

Use the bellman’s algorithm to find the shortest path


Answer :
The
Visited Existed Minimum
The Set S Calculated Wieght 𝝅 Target
Node Path Weight
Path
O S = {O} π(O) = 0 π(O) = 0
A S = {O, A} O→A π(A) = π(O) + w(O, A) = 0 + 40 = 40 π(A) = 40 𝐎→𝐀
B S = {O, A, B} O→B π(B) = min⁡{π(O) + w(O, B)⁡, π(A) + w(A, B)} 𝐀→𝐁
A→B = min{0 + 60, 40 + (−10)} = min{60, 30} = 30 π(B) = 30
C,D S = {O, A, B, C, D} O→C π(C) = min⁡{π(O) + w(O, C)⁡, π(B) + w(B, C)} 𝐁→𝐂
B→C = min{0 + 50, 30 + 20⁡} = 50 π(C) = 50 𝐎→𝐂
A→D π(D) = min⁡{π(A) + w(A, D)⁡, π(B) + w(B, D)⁡}
B→D π(D) = 85 𝐁→𝐃
= min{40 + 70⁡,30 + 55} = min{110, 85} = 85
E S= B→E π(E) = min⁡{π(B) + w(B, E)⁡, π(C) + w(C, E), π(E) = 0 𝐂→𝐄
{O, A, B, C, D, E} C→E π(D) + w(D, E)}
D→E = min 30 + 40, 50 + (−50) + 85 + (−10)}
{
= min{70⁡, 0⁡, 75} = 0
Des S= D → Des π(Des) = min⁡{π(D) + w(D, Des)⁡, π(Des) 𝐄 → 𝐃𝐞𝐬
{O, A, B, C, D, E, Des} E → Des ⁡π(E) + w(E, Des)} = min{85 + 60,0 + 80} = 80
= min{145,80} = 80
There are two shortest path solutions:
𝑶𝒓𝒊𝒈𝒊𝒏⁡ → ⁡𝑨⁡ → 𝑩 → 𝑪 → 𝑬 → 𝑫𝒆𝒔𝒕𝒊𝒏𝒂𝒕𝒊𝒐𝒏 with π(Des) = 40 − 10 + 20 − 50 + 80 = 80
𝑶𝒓𝒊𝒈𝒊𝒏⁡ → ⁡𝑪 → 𝑬 → ⁡𝑫𝒆𝒔𝒕𝒊𝒏𝒂𝒕𝒊𝒐𝒏 with π(Des) = 50⁡– ⁡50⁡ + ⁡80 = 80.

Q.2: STC Company will soon begin laying cable in new neighborhoods in Riyadh
represented as {𝐴, … , 𝐽}. The cable should connect the new neighborhoods with each other.
Some of the paths might be more expensive, because they are longer. So, construct
a minimum spanning tree that would be the one with the lowest total cost, representing the
least expensive path for laying the cable. The network is visualized on the map of Riyadh city
with nodes and paths, representing the neighborhoods and roads respectively. The weights
represent the distances along each path that connects two neighborhoods in 1000 meters.

H
C
G
I

D J

F
B

A 3

Answer : Using Kruskal’s algorithm, that is, finding a set of links (n − 1⁡links⁡for⁡n⁡nodes)
that provides a path between each pair of nodes with shortest total length. We can start with
any node on the network and apply the algorithm, and it will result the same minimum
spanning tree regardless of the starting node. Arbitrarily, I will start with the node A.
Closest Unconnected
Iteration Connected Nodes Arc
Node
1 A B (A, B)
2 A, B D (B, D)
3 A, B, D C (D, C)
4 A, B, D, C F (D, F)
5 A, B, D, C, F E (F, E)
6 A, B, D, C, F, E G (F, G)
7 A, B, D. C, F, E, G H (G, H)
8 A, B, D, C, F, E, G, H I (H, I)
9 A, B, D, C, F, E, G, H, I J (I, J)

You might also like