-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArc.java
More file actions
70 lines (62 loc) · 2.08 KB
/
Copy pathArc.java
File metadata and controls
70 lines (62 loc) · 2.08 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package Graphes;
public class Arc implements Comparable<Arc> {
private final Node begin;
private final Node end;
private Integer value;
/** No value constructor
* @param begin node from which the arc start
* @param end node from which the arc end
*/
public Arc(Node begin, Node end){
this.begin = begin;
this.end = end;
this.value = -666;
}
/** No value constructor
* @param begin node from which the arc start
* @param end node from which the arc end
* @param value cost of this arc
*/
public Arc(Node begin, Node end, Integer value){
this.begin = begin;
this.end = end;
this.value = value;
}
// GETTERS
/** @return the starting node of the arc*/
public Node getBegin() {
return begin;
}
/** @return the ending node of the arc*/
public Node getEnd() {
return end;
}
/** @return the cost of the arc*/
public Integer getValue() {
return value;
}
// SETTERS
/** @param value cost of this arc*/
public void setValue(Integer value) {
this.value = value;
}
// MISCS
/** Convert the param of this arc in a string
* @return string view of the object*/
@Override
public String toString(){
if (value != -666){return "("+begin.getName()+","+end.getName()+"("+value+")"+")";}
return "("+begin.getName()+","+end.getName()+")";
}
/**
* Compare the name of the starting node of this arc to the name of the starting node of the parameter
* @param arc Arc to compare this object with
* @return the value 0 if the argument string is equal to this string;
* a value less than 0 if this string is lexicographically less than the string argument;
* and a value greater than 0 if this string is lexicographically greater than the string argument.*/
@Override
public int compareTo(Arc arc) {
if (begin.getName() == null || arc.getBegin().getName() == null) {return 0;}
return begin.getName().compareTo(arc.begin.getName());
}
}