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 / TmfGraph.java
index 763e6d0926e708dedbdc8f8f36dbda74d0c96a62..715859b6904aa2920ffc97e1e43ddfa75cb0d433 100644 (file)
@@ -243,6 +243,9 @@ public class TmfGraph {
         TmfEdge edge = headNode.getEdge(EdgeDirection.INCOMING_HORIZONTAL_EDGE);
         while (edge != null) {
             headNode = edge.getVertexFrom();
+            if (headNode == vertex) {
+                throw new CycleDetectedException();
+            }
             edge = headNode.getEdge(EdgeDirection.INCOMING_HORIZONTAL_EDGE);
         }
         return headNode;
@@ -343,8 +346,10 @@ public class TmfGraph {
             // process one line
             TmfVertex n = getHead(curr);
             visitor.visitHead(n);
-            while (n != null) {
+            while (true) {
                 visitor.visit(n);
+                visited.add(n);
+
                 // Only visit links up-right, guarantee to visit once only
                 TmfEdge edge = n.getEdge(EdgeDirection.OUTGOING_VERTICAL_EDGE);
                 if (edge != null) {
@@ -360,9 +365,9 @@ public class TmfGraph {
                     visitor.visit(edge, true);
                     n = edge.getVertexTo();
                 } else {
-                    n = null;
+                    // end of the horizontal list
+                    break;
                 }
-                visited.add(n);
             }
         }
     }
This page took 0.041044 seconds and 5 git commands to generate.