private Set<DagNode<T>> getAncestorNodes(Set<DagNode<T>> dagNodes) {
    Set<DagNode<T>> ancestorNodes = new HashSet<>();
    for (DagNode<T> dagNode : dagNodes) {
      LinkedList<DagNode<T>> nodesToExpand = Lists.newLinkedList(this.getParents(dagNode));
      while (!nodesToExpand.isEmpty()) {
        DagNode<T> nextNode = nodesToExpand.poll();
        ancestorNodes.add(nextNode);
        nodesToExpand.addAll(this.getParents(nextNode));
      }
    }
    return ancestorNodes;
  }
private Set < DagNode < T > > getAncestorNodes ( Set < DagNode < T > > dagNodes ) { Set < DagNode < T > > ancestorNodes = new HashSet < > ( ) ; for ( DagNode < T > dagNode : dagNodes ) { LinkedList < DagNode < T > > nodesToExpand = Lists . newLinkedList ( this . getParents ( dagNode ) ) ; while ( ! nodesToExpand . isEmpty ( ) ) { DagNode < T > nextNode = nodesToExpand . poll ( ) ; ancestorNodes . add ( nextNode ) ; nodesToExpand . addAll ( this . getParents ( nextNode ) ) ; } } return ancestorNodes ; }
Get the ancestors of a given set of {@link DagNode}s in the {@link Dag}.
@param dagNodes set of nodes in the {@link Dag}.
@return the union of all ancestors of dagNodes in the dag.