-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedge.java
64 lines (49 loc) · 1.08 KB
/
edge.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
//purpose
//store all data for Kruskal's Algo
public class edge implements Comparable <edge>
{
private int start, end;
private double weight;
//default does not need, just in case
public edge(int row, int column, double weight)
{
this.start = row;
this.end = column;
this.weight = weight;
}
//getter
public int getStart()
{
return start;
}
public int getEnd()
{
return end;
}
public double getWeight()
{
return weight;
}
//setter
public void print(int size)
{
if(this.end % size ==0)
{
System.out.print("\n");
}
System.out.print(String.format("%-6s", this.weight));
}
@Override
public int compareTo(edge compareEdge)
{
if(this.getWeight() > compareEdge.getWeight())
{
return 1;
}
else if(this.getWeight() < compareEdge.getWeight())
{
return -1;
}
return 0;
}
}