diff options
| author | yzhou <yujiao.zhou@gmail.com> | 2015-04-21 10:34:27 +0100 |
|---|---|---|
| committer | yzhou <yujiao.zhou@gmail.com> | 2015-04-21 10:34:27 +0100 |
| commit | 9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8 (patch) | |
| tree | 47511c0fb89dccff0db4b5990522e04f294d795b /src/uk/ac/ox/cs/pagoda/summary/Edge.java | |
| parent | b1ac207612ee8b045244253fb94b866104bc34f2 (diff) | |
| download | ACQuA-9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8.tar.gz ACQuA-9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8.zip | |
initial version
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/summary/Edge.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/summary/Edge.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/summary/Edge.java b/src/uk/ac/ox/cs/pagoda/summary/Edge.java new file mode 100644 index 0000000..79d3041 --- /dev/null +++ b/src/uk/ac/ox/cs/pagoda/summary/Edge.java | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.summary; | ||
| 2 | |||
| 3 | import java.util.Comparator; | ||
| 4 | |||
| 5 | public class Edge { | ||
| 6 | |||
| 7 | Node from, to; | ||
| 8 | String label; | ||
| 9 | |||
| 10 | public String getLabel() { return label; } | ||
| 11 | public Node getFromNode() { return from; } | ||
| 12 | public Node getToNode() {return to; } | ||
| 13 | public String getFromNodeName() { return from.name; } | ||
| 14 | public String getToNodeName() { return to.name; } | ||
| 15 | |||
| 16 | public Edge(Node u, Node v, String stringID) { | ||
| 17 | from = u; | ||
| 18 | to = v; | ||
| 19 | label = stringID; | ||
| 20 | } | ||
| 21 | |||
| 22 | public String toString() { | ||
| 23 | return label + "(\n\t" + from.name + ",\n\t" + to.name + ")"; | ||
| 24 | } | ||
| 25 | |||
| 26 | public static int compareLabels(Edge[] list1, Edge[] list2) { | ||
| 27 | int result = list1.length - list2.length; | ||
| 28 | if (result != 0) return result; | ||
| 29 | for (int i = 0; i < list1.length; ++i) { | ||
| 30 | if ((result = list1[i].label.compareTo(list2[i].label)) != 0) | ||
| 31 | return result; | ||
| 32 | } | ||
| 33 | return 0; | ||
| 34 | } | ||
| 35 | |||
| 36 | public Node getDestinationNode(boolean isOutGoingEdges) { | ||
| 37 | return isOutGoingEdges ? to : from; | ||
| 38 | } | ||
| 39 | |||
| 40 | } | ||
| 41 | |||
| 42 | class EdgeComparatorByNodeName implements Comparator<Edge> { | ||
| 43 | |||
| 44 | @Override | ||
| 45 | public int compare(Edge o1, Edge o2) { | ||
| 46 | int result = o1.label.compareTo(o2.label); | ||
| 47 | if (result != 0) return result; | ||
| 48 | result = o1.from.name.compareTo(o2.from.name); | ||
| 49 | if (result != 0) return result; | ||
| 50 | return o1.to.name.compareTo(o2.to.name); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | class EdgeComparatorByNodeLabel implements Comparator<Edge> { | ||
| 55 | |||
| 56 | @Override | ||
| 57 | public int compare(Edge o1, Edge o2) { | ||
| 58 | int result = o1.label.compareTo(o2.label); | ||
| 59 | if (result != 0) return result; | ||
| 60 | result = o1.from.getLabel().compareTo(o2.from.getLabel()); | ||
| 61 | if (result != 0) return result; | ||
| 62 | result = o1.to.getLabel().compareTo(o2.to.getLabel()); | ||
| 63 | if (result != 0) return result; | ||
| 64 | result = o1.from.getName().compareTo(o2.from.getName()); | ||
| 65 | if (result != 0) return result; | ||
| 66 | result = o1.to.getName().compareTo(o2.to.getName()); | ||
| 67 | return result; | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
