-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertex.java
More file actions
51 lines (46 loc) · 1.2 KB
/
Copy pathVertex.java
File metadata and controls
51 lines (46 loc) · 1.2 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
package bfs;
import java.util.ArrayList;
import java.util.List;
/*
* The Vertex class is used as a data structure all the necesary variables
* together with their setters and getters are defined in this class
* name is the room name, visited is a boolean we use to check if the room
* is visited, neigbours is a list of type Vertex because all the neigbours have
* all the properties of the Vertex class. we can define neigbours as rooms
* connected to a room.
*/
public class Vertex {
private String name;
private boolean visited;
private List<Vertex> neigbours;
private List<Vertex> parent;
public Vertex(String name) {
this.name = name;
this.neigbours = new ArrayList<>();
this.parent = new ArrayList<>();
}
public List<Vertex> getParent() {
return parent;
}
public void setParent(Vertex parent) {
this.parent.add(parent);
}
public void addNeigbour(Vertex vertex) {
this.neigbours.add(vertex);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isVisited() {
return visited;
}
public void setVisited(boolean visited) {
this.visited = visited;
}
public List<Vertex> getNeigbours() {
return neigbours;
}
}