forked from softwareEngineering3/matala1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vertex.java
44 lines (41 loc) · 978 Bytes
/
vertex.java
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
import java.util.ArrayList;
class vertex {
public int name;
public ArrayList<edge> edges;
public double dist;
public int previous;
public boolean visited;
public int count;
public vertex(int name, double dist) {
this.name = name;
this.dist = dist;
previous = -1;
visited = false;
edges = new ArrayList<>();
count=0;
}
public vertex(vertex v) {
this.name = v.name;
this.dist = v.dist;
this.previous = v.previous;
this.visited = v.visited;
this.count=v.count;
this.edges = new ArrayList<>();
for(int i=0;i<v.edges.size();i++){
this.edges.add(v.edges.get(i));
}
}
public vertex(vertex v,int num) {
this.name = v.name;
this.edges = new ArrayList<>();
for(int i=0;i<v.edges.size();i++){
this.edges.add(v.edges.get(i));
}
}
public String toString() {
String s= "name is" + name+" sons are:";
for(int i=0;i<edges.size();i++)
s+=edges.get(i).toString();
return s;
}
}