Java Data structure

profileMUNTHA
Project_4_Indications.pdf

UMUC – CMSC 350

Project 4 - Indications

Below please find DGraph, a skeleton definition (Java-like pseudo-code) of a directed graph class with generics,

allowing a generic type for the vertex names as required by Project 4.

Note that the definitions of attributes and methods are incomplete in terms of accessibility, visibility, thrown

exceptions and definition body (you should specify all these elements according to your specific design).

Other attributes or methods can be added if necessary (reason should be given in the solution description

document).

public class DGraph<T> {

... List<List<Integer>> adjancencyList;

... Map<T, Integer> mapTtoInteger;

// ... other attributes

// default constructor

public DGraph<T>() {

adjacentList = new ArrayList<LinkedList<Integer>>();

mapTtoInteger = new HashMap<T, Integer>();

}

// short (but incomplete) specification of the methods

... addVertex(T vertex) ...

... addEdge(T vertexFrom, T vertexTo) ...

public String topOrdGeneration(T startVertex) ...

// ... other methods (if necessary)

}

I recommend defining a buildDGraphFromFile method in the P4GUI class:

... buildDGraphFromFile( file specification ) ...

From this method, addVertex and addEdge defined in the DGraph class may be invoked with String

parameters representing the vertices names read from the input file.

Note. If the method buildDGraphFromFile is defined in the DGraph class, cast operations may be required

therefore it is recommended to be defined in the P4GUI class.