I want to get distance of all nodes from all other nodes. For example, if I have 4 nodes then i want distance of path
(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)
i.e. all pairs that are possible
Note: Every node does have a path from every other node.
My approach : I thought of applying Dijkstra's algorithm but it works for a single source and then I have to apply it for every node as source and then take out unique pairs from them which would have very high complexity.
Edit : What would be the case if I have a minimum spanning Tree and have to perform the same task? I mean there is just one path from one node to other.