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

Data Structures for Dijkstra's Algorithm

The implementation of Dijkstra's algorithm described below uses the Entry struct declared in Program gif. Each Entry value has three fields, known, distance, and predecessor, which correspond to the variables tex2html_wrap_inline71254, tex2html_wrap_inline71256, and tex2html_wrap_inline71258, respectively.

   program51595
Program: GraphAlgorithms Entry struct.

In each pass of its operation, Dijkstra's algorithm selects from the set of vertices for which the shortest-path is not yet known the one with the smallest tentative distance. Therefore, we use a priority queue to represent this set of vertices.

The priority assigned to a vertex is its tentative distance. The class Association class introduced in Program gif is used to associate a priority with a given vertex instance.


next up previous contents index

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