next up previous contents
Next: NetWorKs Interface Up: NetWorKs & Graph Algorithms Previous: Graph Algorithms Interface

Algorithms Class

The GraphAlgorithm abstract class defines the interface for the NetWorKs program to ``instruct'' and ``query'' GraphAlgorithms, but the NetWorKs program must also be able to determine what GraphAlgorithms currently exist. To provide this information, the Algorithms class contains an array of the currently available GraphAlgorithm objects. Whenever a new GraphAlgorithm is developed, the new GraphAlgorithm is added to the array in the Algorithms class. This means that only the new class and the Algorithms class need be compiled. It also means that the source code for the NetWorKs program does not need to be available in order to add new graph algorithms.

package GraphStuff;

public class Algorithms {

   public static final GraphAlgorithm[] algs
     = {new Kruskal(),
        new Topological(),
        new Dijkstra(),
        new DepthFirst()};

}



Kelly Waters
Mon Oct 27 18:18:15 EST 1997