forked from srinathr91/TestJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertex.java
More file actions
74 lines (59 loc) · 1.09 KB
/
Vertex.java
File metadata and controls
74 lines (59 loc) · 1.09 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.util.ArrayList;
import java.util.List;
public class Vertex {
// A list of all vertices adjacent to this one
private List<Vertex> adjacentVertices;
// Flag denoting whether a vertex has already been visited
private boolean visited;
// Number value associated with each vertex
private int value;
/**
*
*/
public Vertex(int value) {
this.adjacentVertices = new ArrayList<Vertex>();
this.visited = false;
this.value = value;
}
public int getValue() {
return this.value;
}
public void setValue(int value) {
this.value = value;
}
/**
*
* @return
*/
public boolean isVisited() {
return visited;
}
/**
*
* @param visited
*/
public void setVisited(boolean visited) {
this.visited = visited;
}
/**
*
* @return
*/
public List<Vertex> getAdjacentVertices() {
return adjacentVertices;
}
/**
*
* @param newVertex
*/
public void addAdjacentNode(Vertex newVertex) {
this.adjacentVertices.add(newVertex);
}
/**
*
* @param v
*/
public void removeAdjacentNode(Vertex v) {
this.adjacentVertices.remove(v);
}
}