edited by
493 views

1 Answer

Best answer
1 votes
1 votes

Diameter and longest path in a graph are not the same thing, 

Diameter of graph can be found easily with the help of all pair shortest path lengths while longest path of graph is very hard to calculate for all type of graphs.

Diameter of graph is maximum of all pair shortest path lengths

if graph have  4 nodes then diameter will be max( SP( 1 - 2 ) , SP( 1 - 3 ) ,  SP( 1 - 4 ) , SP( 2 - 3 ) , SP( 2 - 4 ) , SP( 3 - 4 ) )

where SP( u - v ) :  shortest path length between u and v.

And longest path length is any path starting  from any node U to any node V  [ U -> a1 - >a2- > a3 -> ...... V ]    such that  all nodes involved in the path including U and V , are different ( simple path )     and sum of edges is as maximum as possible.

Here cost[U-V]  is maximum cost.

It is not necessary that diameter and longest path length have to be equal , they may be different 

In general, they are not the same thing. Also, for the general graph, it is easy to compute the diameter, but hard to compute the longest path. In the graph below, the diameter is 4. A path from 6 to 2 is highlighted, which is of length 4.

enter image description here

However, there is a longer (simple) path from 6 to 2 of length 5.

enter image description here

And in Dijkstra's algorithm it is not necessary that every edge relaxed only once  ( False ) 

selected by

Related questions

3 votes
3 votes
0 answers
2
Hitoshi asked Oct 15, 2017
1,640 views
While going through dijkstra's algorithm, there is a term "decrease key". I am not getting the meaning when it says "we do decrease key operation". What exactly we do and...
1 votes
1 votes
1 answer
4