-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVertex.java
54 lines (43 loc) · 843 Bytes
/
Vertex.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.util.ArrayList;
public class Vertex<T>{
T value;
public ArrayList<Vertex<T>> dependencies;
public boolean visited;
int dist;
T path;
int indegree;
int timeStamp;
public Vertex(T value){
dependencies = new ArrayList<Vertex<T>>();
this.value = value;
this.dist = 0;
this.indegree = 0;
this.visited = false;
this.path = null;
}
public T getValue(){
return this.value;
}
public int getDist(){
return dist;
}
public void addAdj(Vertex<T> adj){
dependencies.add(adj);
}
@Override
public String toString(){
return(value +" : "+ dependencies );
}
/*
* Returns true if the vertex has an indegree of zero
*/
public boolean isBasic(){
return (dependencies.size() == 0);
}
public void setTime( int t ){
this.timeStamp = t;
}
public void setDist( int d ){
this.dist = d;
}
}