-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertex.java
More file actions
62 lines (53 loc) · 1.13 KB
/
Vertex.java
File metadata and controls
62 lines (53 loc) · 1.13 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
import java.util.ArrayList;
import java.util.HashSet;
public class Vertex
{
public ArrayList<Vertex> neighbours;
public HashSet<Vertex> uniqueNeighbours;
public int y;
public int x;
public int n; // The original number of this vertex
public int currentN; // The modified number of this vertex
public Vertex(int y, int x, int n)
{
neighbours = new ArrayList<Vertex>();
uniqueNeighbours = new HashSet<Vertex>();
this.y = y;
this.x = x;
this.n = n;
currentN = n;
}
public void addNeighbour(Vertex v)
{
neighbours.add(v);
uniqueNeighbours.add(v);
}
public void removeNeighbour(Vertex v)
{
neighbours.remove(v);
if (!neighbours.contains(v))
{
uniqueNeighbours.remove(v);
}
}
public ArrayList<Vertex> getNeighbours()
{
return new ArrayList<Vertex>(neighbours);
}
public ArrayList<Vertex> getUniqueNeighbours()
{
return new ArrayList<Vertex>(uniqueNeighbours);
}
public int getAvailableEdgesCount()
{
return neighbours.size();
}
public int getNeighbourCount()
{
return uniqueNeighbours.size();
}
public String toString()
{
return "V: " + x + "," + y + " - " + n;
}
}