}
/**
- * 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
*/
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);
}
/**
* @return The list of vertices for the object
*/
public List<TmfVertex> getNodesOf(IGraphWorker obj) {
- return NonNullUtils.checkNotNull(fNodeMap.get(obj));
+ return fNodeMap.get(obj);
}
/**
* @return The vertex map
*/
public Set<IGraphWorker> getWorkers() {
- return NonNullUtils.checkNotNull(ImmutableSet.copyOf(fNodeMap.keySet()));
+ return ImmutableSet.copyOf(fNodeMap.keySet());
}
/**
HashSet<TmfVertex> visited = new HashSet<>();
stack.add(start);
while (!stack.isEmpty()) {
- TmfVertex curr = NonNullUtils.checkNotNull(stack.pop());
+ TmfVertex curr = stack.pop();
if (visited.contains(curr)) {
continue;
}