예제 #1
0
 private void computeDependencies(List<GraphNode<T>> nodes) {
   List<GraphNode<T>> nextNodesToDisplay = null;
   for (GraphNode<T> node : nodes) {
     if (!isAlreadyEvaluated(node)) {
       List<GraphNode<T>> comingInNodes = node.getComingInNodes();
       if (areAlreadyEvaluated(comingInNodes)) {
         listener.evaluating(node.value);
         evaluatedNodes.add(node);
         List<GraphNode<T>> goingOutNodes = node.getGoingOutNodes();
         if (goingOutNodes != null) {
           if (nextNodesToDisplay == null) nextNodesToDisplay = new ArrayList<GraphNode<T>>();
           // add these too, so they get a chance to be displayed
           // as well
           nextNodesToDisplay.addAll(goingOutNodes);
         }
       } else {
         if (nextNodesToDisplay == null) nextNodesToDisplay = new ArrayList<GraphNode<T>>();
         // the checked node should be carried
         nextNodesToDisplay.add(node);
       }
     }
   }
   if (nextNodesToDisplay != null) {
     computeDependencies(nextNodesToDisplay);
   }
   // here the recursive call ends
 }
예제 #2
0
 public void computeDependencies() {
   List<GraphNode<T>> orphanNodes = getOrphanNodes();
   List<GraphNode<T>> nextNodesToDisplay = new ArrayList<GraphNode<T>>();
   if (orphanNodes != null) {
     for (GraphNode<T> node : orphanNodes) {
       listener.evaluating(node.value);
       evaluatedNodes.add(node);
       nextNodesToDisplay.addAll(node.getGoingOutNodes());
     }
     computeDependencies(nextNodesToDisplay);
   }
 }