Graph2

Graph2 - import import import i import java.util.*;...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.*; import java.io.*; import DataStructures.*; import DataStructures.LinkedList; i class Vertex { String name; // Vertex name LinkedList adj; // Adjacent vertices int dist; // Cost Vertex path; // Previous vertex on shortest path public Vertex( String nm ) { name = nm; adj = new LinkedList( ); reset( ); } public void reset( ) { dist = Graph.INFINITY; path = null; } } class MapEntry implements Hashable { String vertexName; Vertex storedVertex; public MapEntry( String name ) { vertexName = new String( name ); storedVertex = null; } public int hash( int tableSize ) { return QuadraticProbingHashTable.hash( vertexName, tableSize ); } public boolean equals( Object rhs ) vertexName.equals( ((MapEntry)rhs).vertexName ); } } // Of course, this file should be Graph.java, but there's already // version 1. So this will give an error if compiled at the same time // as Graph.java. class Graph { public static final int INFINITY = Integer.MAX_VALUE; private QuadraticProbingHashTable vertexMap = new QuadraticProbingHashTable( ); // Maps vertices to internal Vertex private LinkedList allVertices = new LinkedList( ); // List of vertices int numVertices = 0;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Graph2 - import import import i import java.util.*;...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online