-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertex.java
More file actions
56 lines (43 loc) · 1 KB
/
Copy pathVertex.java
File metadata and controls
56 lines (43 loc) · 1 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
package com.geeksforgeeks.graph;
import java.util.ArrayList;
import java.util.List;
public class Vertex<T> {
long id;
int data;
List<Edge<T>> edges = new ArrayList<>();
List<Vertex<T>> adjacentVertex = new ArrayList<>();
public Vertex(long id) {
this.id = id;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public int getData() {
return data;
}
public void setData(int data) {
this.data = data;
}
public List<Edge<T>> getEdges() {
return edges;
}
public void setEdges(List<Edge<T>> edges) {
this.edges = edges;
}
public List<Vertex<T>> getAdjacentVertex() {
return adjacentVertex;
}
public void addAdjacentVertex(Edge e, Vertex v) {
edges.add(e);
adjacentVertex.add(v);
}
public int getDegree() {
return edges.size();
}
public String toString(){
return String.valueOf(id);
}
}