in saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/GraphCycleDetectorImpl.java [49:65]
private void traverse(Queue<Node<T>> orphanNodes, Map<Node<T>, Set<Node<T>>> nodeParents) {
while (!orphanNodes.isEmpty()) {
Node<T> node = orphanNodes.poll();
for(Node<T> child : node.children()) {
Set<Node<T>> parent = nodeParents.get(child);
if (parent == null) {
parent = new HashSet<>(child.parents());
nodeParents.put(child, parent);
}
parent.remove(node);
if (nodeParents.get(child).isEmpty()) {
orphanNodes.add(child);
}
}
}
}