T
- type of the data stored in the verticespublic class Graph<T>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) int[] |
dp |
protected int |
longestPathLength |
protected int |
n |
(package private) int |
tempLen |
protected java.util.ArrayList<Vertex<T>> |
vertices |
Constructor and Description |
---|
Graph(int n)
constructor for DirectGraph class
|
Modifier and Type | Method and Description |
---|---|
void |
addEdge(int firstVertexLabel,
int secondVertexLabel)
method add a new vertex to the graph
|
void |
addVertex(int label)
method to add a new vertex to the graph
|
int |
calculateLongestPath()
to calculate the longest path in the current graph
|
int |
getLongestPathLength() |
java.util.ArrayList<Vertex<T>> |
getVertices() |
void |
setLongestPathLength(int longestPathLength) |
void |
setVertices(java.util.ArrayList<Vertex<T>> vertices) |
void |
visit(Vertex<T> vertex) |
protected int longestPathLength
int[] dp
int tempLen
protected int n
public void addVertex(int label)
label
- the label assigned to the new vertexpublic void addEdge(int firstVertexLabel, int secondVertexLabel)
firstVertexLabel
- the label of the first vertexsecondVertexLabel
- the label of the second vertexpublic int calculateLongestPath()
public int getLongestPathLength()
public void setLongestPathLength(int longestPathLength)