Cover Data Structures and Algorithms with Object-Oriented Design Patterns in Java
next up previous contents index

All-Pairs Source Shortest Path

In this section we consider the all-pairs, shortest path problem: Given an edge-weighted graph tex2html_wrap_inline69997, for each pair of vertices in tex2html_wrap_inline69999 find the length of the shortest weighted path between the two vertices.

One way to solve this problem is to run Dijkstra's algorithm tex2html_wrap_inline70423 times in turn using each vertex in tex2html_wrap_inline69999 as the initial vertex. Therefore, we can solve the all-pairs problem in tex2html_wrap_inline71313 time when adjacency lists are used, and tex2html_wrap_inline71315, when adjacency matrices are used. However, for a dense graph ( tex2html_wrap_inline70397) the running time of Dijkstra's algorithm is tex2html_wrap_inline71319, regardless of the representation scheme used.




next up previous contents index

Bruno Copyright © 1998 by Bruno R. Preiss, P.Eng. All rights reserved.