next up previous index
Next: Arc insertion Up: Java implementation Previous: The nodeMap container   Index

The WeightedGraph constructor

The instance variables and constructor for the WeightedGraph class are now given by:
protected LookupTable nodeMap;
private int nrNodes;          
private int nrArcs;           

public WeightedGraph() {
    nodeMap = new DoubleHashingTable();
    nrNodes = 0;
    nrArcs = 0;
}
This constructs an empty graph. The variables nrNodes and nrArcs count the numbers of nodes and arcs. Initially there are none. For definiteness the nodeMap table is implemented by a DoubleHashingTable, but any implementation of the LookupTable interface would serve as well. Note that the nodeMap table is given protected status so that extensions of the WeightedGraph class in the same package can have access it. The same remark applies to the Node and Tip classes discussed previously.



Peter Williams 2005-06-07