forked from tushartushar/DesigniteJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEdge.java
More file actions
46 lines (36 loc) · 882 Bytes
/
Edge.java
File metadata and controls
46 lines (36 loc) · 882 Bytes
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
package Designite.utils.models;
import java.util.ArrayList;
import java.util.List;
public class Edge {
private Vertex firstVertex;
private Vertex secondVertex;
private List<Vertex> edge;
public Edge(Vertex firstVertex, Vertex secondVertex) {
this.firstVertex = firstVertex;
this.secondVertex = secondVertex;
edge = new ArrayList<>();
edge.add(firstVertex);
edge.add(secondVertex);
}
public Vertex getFirstVertex() {
return firstVertex;
}
public Vertex getSecondVertex() {
return secondVertex;
}
public List<Vertex> getVertices() {
return edge;
}
public boolean containsVertex(Vertex vertex) {
return edge.contains(vertex);
}
public Vertex getOtherVertex(Vertex vertex) {
if (edge.get(0).equals(vertex)) {
return edge.get(1);
} else if (edge.get(1).equals(vertex)) {
return edge.get(0);
} else {
return null;
}
}
}