-
Notifications
You must be signed in to change notification settings - Fork 1
/
vertex.java
116 lines (113 loc) · 2.15 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import java.util.ArrayList;
class vertex {
private int name;
private ArrayList<edge> edges;
private double dist;
private int previous;
private boolean visited;
private 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;
}
/**
* @return the name
*/
public int getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(int name) {
this.name = name;
}
/**
* @return the edges
*/
public ArrayList<edge> getEdges() {
return edges;
}
/**
* @param edges the edges to set
*/
public void setEdges(ArrayList<edge> edges) {
this.edges = edges;
}
/**
* @return the dist
*/
public double getDist() {
return dist;
}
/**
* @param dist the dist to set
*/
public void setDist(double dist) {
this.dist = dist;
}
/**
* @return the previous
*/
public int getPrevious() {
return previous;
}
/**
* @param previous the previous to set
*/
public void setPrevious(int previous) {
this.previous = previous;
}
/**
* @return the visited
*/
public boolean isVisited() {
return visited;
}
/**
* @param visited the visited to set
*/
public void setVisited(boolean visited) {
this.visited = visited;
}
/**
* @return the count
*/
public int getCount() {
return count;
}
/**
* @param count the count to set
*/
public void setCount(int count) {
this.count = count;
}
}