Use of weights in Dijkstra algorithm

554 Views Asked by At

In Dijkstra algorithm, what is the use of weights(distance measures) preassigned to edges? Why cant we just update the distances of vertices by using path length data structure? I think it is redundant and sometimes increases the time complexity. Say suppose we have a graph like one vertex adjacent to two neighbours with distance on the corresponding edges to be say $9$ and $10$. Then, though path length is same $1$, the distance assigned to the two adjacent vertices after the first step would be $9$ and $10$ even though the path lengths are same. Isn't it? Any clarifications? Thanks beforehand.