in Algorithms
267 views
1 vote
1 vote

Question statement: In a undirected graph,if we increase weight of each edge by 1 unit ,shortest path remains same (Given:False)

Solution says second shortest path may become smaller after increasing the weight.

I can't figure out why. Any example or source for this will be helpful..

in Algorithms
267 views

3 Comments

//Observe shortest path from a to e.

Before:

      1           1           1             1

a ---------b---------c---------d------------e

 \                                                      /

   \_____________f______________/

         3                         2


After:

      2           2           2             2

a ---------b---------c---------d------------e

 \                                                      /

   \_____________f______________/

         4                         3

1
1
Let there be a quadrilateral ABCD.  AB=1, BC=2, CD= 3 and AD=7. So shortest path between A to D is 6 i.e. A-B-C-D

Now increase by one.

AB=2, BC=3, CD=4 and AD=8.

Now the shortest path from A to D is 8 i.e the direct edge connecting A and D and not via B and C because it weighs 2+3+4=9.
2
2
Good illustration,Thank you!
1
1

Please log in or register to answer this question.