blob: 79d3041f3d9eac08fcee6439710821451cb853db (
plain) (
blame)
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 uk.ac.ox.cs.pagoda.summary;
import java.util.Comparator;
public class Edge {
Node from, to;
String label;
public String getLabel() { return label; }
public Node getFromNode() { return from; }
public Node getToNode() {return to; }
public String getFromNodeName() { return from.name; }
public String getToNodeName() { return to.name; }
public Edge(Node u, Node v, String stringID) {
from = u;
to = v;
label = stringID;
}
public String toString() {
return label + "(\n\t" + from.name + ",\n\t" + to.name + ")";
}
public static int compareLabels(Edge[] list1, Edge[] list2) {
int result = list1.length - list2.length;
if (result != 0) return result;
for (int i = 0; i < list1.length; ++i) {
if ((result = list1[i].label.compareTo(list2[i].label)) != 0)
return result;
}
return 0;
}
public Node getDestinationNode(boolean isOutGoingEdges) {
return isOutGoingEdges ? to : from;
}
}
class EdgeComparatorByNodeName implements Comparator<Edge> {
@Override
public int compare(Edge o1, Edge o2) {
int result = o1.label.compareTo(o2.label);
if (result != 0) return result;
result = o1.from.name.compareTo(o2.from.name);
if (result != 0) return result;
return o1.to.name.compareTo(o2.to.name);
}
}
class EdgeComparatorByNodeLabel implements Comparator<Edge> {
@Override
public int compare(Edge o1, Edge o2) {
int result = o1.label.compareTo(o2.label);
if (result != 0) return result;
result = o1.from.getLabel().compareTo(o2.from.getLabel());
if (result != 0) return result;
result = o1.to.getLabel().compareTo(o2.to.getLabel());
if (result != 0) return result;
result = o1.from.getName().compareTo(o2.from.getName());
if (result != 0) return result;
result = o1.to.getName().compareTo(o2.to.getName());
return result;
}
}
|