analysis: basic checks for acyclic property of TmfGraph
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.graph.core / src / org / eclipse / tracecompass / analysis / graph / core / base / TmfVertex.java
index 220390c394c60f7be37de2d6721378571f13ffff..1a9aaaa01ad1c86ab2eca6bd5b5d43c1c8c309a6 100644 (file)
@@ -169,6 +169,7 @@ public class TmfVertex implements Comparable<TmfVertex> {
      */
     public TmfEdge linkHorizontal(TmfVertex to) {
         checkTimestamps(to);
+        checkNotSelf(to);
         return linkHorizontalRaw(to);
     }
 
@@ -188,6 +189,7 @@ public class TmfVertex implements Comparable<TmfVertex> {
      */
     public TmfEdge linkVertical(TmfVertex to) {
         checkTimestamps(to);
+        checkNotSelf(to);
         return linkVerticalRaw(to);
     }
 
@@ -205,6 +207,13 @@ public class TmfVertex implements Comparable<TmfVertex> {
         }
     }
 
+    private void checkNotSelf(TmfVertex to) {
+        if (this == to) {
+            throw new IllegalArgumentException(Messages.TmfVertex_CannotLinkToSelf);
+        }
+    }
+
+
     /**
      * Get an edge to or from this vertex in the appropriate direction
      *
This page took 0.02715 seconds and 5 git commands to generate.