0% found this document useful (0 votes)
54 views4 pages

Chat GPT

The document outlines the process of calculating the shortest path from a source vertex A to other vertices (B, C, D, E, F) in a network represented as a graph with weighted edges. It details the initialization of distances and the step-by-step updates of paths and costs as nodes are processed. The final results show the shortest paths and costs from A to each vertex, along with a note on the potential disadvantage of flooding in the network.

Uploaded by

21vcetcse058
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)
54 views4 pages

Chat GPT

The document outlines the process of calculating the shortest path from a source vertex A to other vertices (B, C, D, E, F) in a network represented as a graph with weighted edges. It details the initialization of distances and the step-by-step updates of paths and costs as nodes are processed. The final results show the shortest paths and costs from A to each vertex, along with a note on the potential disadvantage of flooding in the network.

Uploaded by

21vcetcse058
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

11/25/24, 10:58 PM ChatGPT

Problem
We are calculating the shortest path from source vertex A to all other vertices (B, C, D, E, F) in the
network.

Network
The network is represented as a graph, where:

Each node (A, B, C, etc.) represents a router.

Each edge (A-B, A-D, etc.) has a cost.

Initialization
1. A is the source vertex.

2. Start with:

D(X): Distance (cost) from A to vertex X.

P(X): Previous node on the path from A to X.

Step 1: Initialization
Initially, only the neighbors of A have known costs:

Cost to B = 2

Cost to D = 1

Cost to C = 5

Cost to E and F = ∞ (not directly connected).

Step N D(B), P(B) D(C), P(C) D(D), P(D) D(E), P(E) D(F), P(F)

1 A 2, A 5, A 1, A ∞ ∞

Step 2: Add D (Smallest Cost)


Among the nodes, D has the smallest cost (1).

Add D to N (set of processed nodes).

Update paths through D:

1. A to B:

D(B) = min(2, 1 + c(D, B)) = min(2, 3) = 2.


No change for B.

2. A to C:

D(C) = min(5, 1 + c(D, C)) = min(5, 4) = 4.


Update D(C) = 4, P (C) = D.
3. A to E:

D(E) = min(∞, 1 + c(D, E)) = min(∞, 2) = 2.

[Link] 1/4
11/25/24, 10:58 PM ChatGPT

Update D(E) = 2, P (E) = D.

Step N D(B), P(B) D(C), P(C) D(D), P(D) D(E), P(E) D(F), P(F)

2 AD 2, A 4, D 1, A 2, D ∞

Step 3: Add E (Smallest Cost)


Next smallest cost is E (2).

Add E to N.

Update paths through E:

1. A to B:

D(B) = min(2, 2 + c(E, B)) = min(2, ∞) = 2.


No change for B.

2. A to C:

D(C) = min(4, 2 + c(E, C)) = min(4, 3) = 3.


Update D(C) = 3, P (C) = E .
3. A to F:

D(F ) = min(∞, 2 + c(E, F )) = min(∞, 4) = 4.


Update D(F ) = 4, P (F ) = E .

Step N D(B), P(B) D(C), P(C) D(D), P(D) D(E), P(E) D(F), P(F)

3 ADE 2, A 3, E 1, A 2, D 4, E

Step 4: Add B (Smallest Cost)


Next smallest cost is B (2).

Add B to N.

Update paths through B:

1. A to C:

D(C) = min(3, 2 + c(B, C)) = min(3, 5) = 3.


No change for C.

2. A to F:

D(F ) = min(4, 2 + c(B, F )) = min(4, ∞) = 4.


No change for F.

Step N D(B), P(B) D(C), P(C) D(D), P(D) D(E), P(E) D(F), P(F)

4 ADEB 2, A 3, E 1, A 2, D 4, E

Step 5: Add C (Smallest Cost)


[Link] 2/4
11/25/24, 10:58 PM ChatGPT

Next smallest cost is C (3).

Add C to N.

Update paths through C:

1. A to F:

D(F ) = min(4, 3 + c(C, F )) = min(4, 8) = 4.


No change for F.

Step N D(B), P(B) D(C), P(C) D(D), P(D) D(E), P(E) D(F), P(F)

5 ADEBC 2, A 3, E 1, A 2, D 4, E

Step 6: Add F (Smallest Cost)


Finally, F is added to N.

Step N D(B), P(B) D(C), P(C) D(D), P(D) D(E), P(E) D(F), P(F)

6 ADEBCF 2, A 3, E 1, A 2, D 4, E

Result
The shortest paths from A to all other vertices:

A to B: Cost = 2, Path = A → B

A to C: Cost = 3, Path = A → E → C

A to D: Cost = 1, Path = A → D

A to E: Cost = 2, Path = A → D → E

A to F: Cost = 4, Path = A → E → F

Disadvantage
Flooding (excessive traffic) can occur, causing delays or infinite loops.
This can be resolved using a Time-To-Live (TTL) field.

2/2

[Link] 3/4
11/25/24, 10:58 PM ChatGPT

The graph shows nodes (A, B, C, D, E, F) connected by weighted edges. The weights represent the
cost between nodes.

[Link] 4/4

You might also like