X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=analysis%2Forg.eclipse.tracecompass.analysis.graph.core%2Fsrc%2Forg%2Feclipse%2Ftracecompass%2Fanalysis%2Fgraph%2Fcore%2Fbase%2FTmfGraph.java;h=d59a8bc6069b17d2641ad427f6ad20d4c132d679;hb=0e4f957eff33d35923105497af515178953cacbc;hp=561e0c5fd80f76aab183446112ffe7d699737154;hpb=df2597e06aa1e8f2a6ea84db36d7e1e51e5f410d;p=deliverable%2Ftracecompass.git diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/base/TmfGraph.java b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/base/TmfGraph.java index 561e0c5fd8..d59a8bc606 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/base/TmfGraph.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/base/TmfGraph.java @@ -218,7 +218,8 @@ public class TmfGraph { } /** - * Returns the head node of the first object of the nodeMap + * Returns the head node of the object of the nodeMap that has the earliest + * head vertex time * * @return The head vertex */ @@ -226,7 +227,12 @@ public class TmfGraph { if (fNodeMap.isEmpty()) { return null; } - return getHead(NonNullUtils.checkNotNull(fNodeMap.keySet().iterator().next())); + IGraphWorker headWorker = fNodeMap.keySet().stream() + .filter(k -> !fNodeMap.get(k).isEmpty()) + .sorted((k1, k2) -> fNodeMap.get(k1).get(0).compareTo(fNodeMap.get(k2).get(0))) + .findFirst() + .get(); + return getHead(headWorker); } /** @@ -259,7 +265,7 @@ public class TmfGraph { * @return The list of vertices for the object */ public List getNodesOf(IGraphWorker obj) { - return NonNullUtils.checkNotNull(fNodeMap.get(obj)); + return fNodeMap.get(obj); } /** @@ -279,7 +285,7 @@ public class TmfGraph { * @return The vertex map */ public Set getWorkers() { - return NonNullUtils.checkNotNull(ImmutableSet.copyOf(fNodeMap.keySet())); + return ImmutableSet.copyOf(fNodeMap.keySet()); } /** @@ -339,7 +345,7 @@ public class TmfGraph { HashSet visited = new HashSet<>(); stack.add(start); while (!stack.isEmpty()) { - TmfVertex curr = NonNullUtils.checkNotNull(stack.pop()); + TmfVertex curr = stack.pop(); if (visited.contains(curr)) { continue; }