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.
However, there is a longer (simple) path from 6 to 2 of length 5.
And in Dijkstra's algorithm it is not necessary that every edge relaxed only once ( False )