-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphEdge.java
More file actions
46 lines (38 loc) · 987 Bytes
/
GraphEdge.java
File metadata and controls
46 lines (38 loc) · 987 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
// Class that represents an edge of a graph
public class GraphEdge {
private GraphNode origin;
private GraphNode destination;
int type;
String label;
// Constructs an edge between points u and v, with given type and label
public GraphEdge(GraphNode u, GraphNode v, int type, String label) {
origin = u;
destination = v;
this.type = type;
this.label = label;
}
// Returns the first endpoint of this edge
public GraphNode firstEndpoint() {
return origin;
}
// Returns the second endpoint of this edge
public GraphNode secondEndpoint() {
return destination;
}
// Setter method for edge type
public void setType(int newType) {
type = newType;
}
// Getter method for edge type
public int getType() {
return type;
}
// Getter method for edge label
public String getLabel() {
return label;
}
// Setter method for edge label
public void setLabel(String newLabel) {
label = newLabel;
}
}