Creates a DiGraphIterator. It will iterate once for every node.
@param root
@param edges
1041
public static <T> DiGraphIterator<T> getInstance(T root, Function<? super T, ? extends Collection<T>> edges)
    {
        return new DiGraphIterator<>(root, (y)->edges.apply(y).stream());
    }
819385
private void recursiveFindSuperAreas(AreaImpl root)
    {
        for (int i = 0; i < root.getChildCount(); i++)
            recursiveFindSuperAreas((AreaImpl) root.getChildAt(i));
        findSuperAreas(root, depthLimit);
    }
    
    /**
     * Creates syntetic super areas by grouping the subareas of the given area.
     * @param the root area to be processed
     * @param passlimit the maximal number of passes while some changes occur 
     */ 
    public void findSuperAreas(AreaImpl root, int passlimit)
    {
        if (root.getChildCount() > 0)
        {
            boolean changed = true;
            int pass = 0;
            root.createSeparators();
            while (changed && pass < passlimit)
            {
                changed = false;
                
                GroupAnalyzer groups = createGroupAnalyzer(root);
                
                Vector<Area> chld = new Vector<Area>();
                chld.addAll(root.getChildren());
                while (chld.size() > 1) //we're not going to group a single element
                {
                    //get the super area
                    Vector<AreaImpl> selected = new Vector<AreaImpl>();
                    int index = root.getIndex(chld.firstElement());
                    AreaImpl grp = null;
                    if (chld.firstElement().isLeaf())
                        grp = groups.findSuperArea((AreaImpl) chld.firstElement(), selected);
                    if (selected.size() == root.getChildCount())
                    {
                        //everything grouped into one group - it makes no sense to create a new one
                        //System.out.println("(contains all)");
                        break;
                    }
                    else
                    {
                        //add a new area
                        if (selected.size() > 1)
                        {
                            root.insertChild(grp, index);
                            //add(grp); //add the new group to the end of children (so that it is processed again later)
                            for (AreaImpl a : selected)
                                grp.appendChild(a);
                            chld.removeAll(selected);
                            grp.updateTopologies();;
                            findSuperAreas(grp, passlimit - 1); //in the next level, we use smaller pass limit to stop the recursion
                            changed = true;
                        }
                        else
                        {
                             //couldn't group the first element -- remove it and go on
                            chld.removeElementAt(0);
                        }
                    }
                }
                root.updateTopologies();
                root.removeSimpleSeparators();
                //System.out.println("Pass: " + pass + " changed: " + changed);
                pass++;
            }
        }
    }

}
633820
@Nonnull
    public static <N, E> SSSPResult<N, E> findSSSP(Graph<N, E> graph, N init, EdgeWeights<E> edgeWeights) {
        DijkstraSSSP<N, E> dijkstra = new DijkstraSSSP<>(graph, init, edgeWeights);
        dijkstra.findSSSP();
        return dijkstra;
    }
397657
private void handleAllRoots() {
		int totalFound = 0;
		double r = 1;
		int iter = 0;

		// increase the search region centered around 0 until at least one root has been found
		while( iter++ < maxBoundIterations && (totalFound=sturm.countRealRoots(-r,r)) <= 0 ) {
			r = 2*r*r;
		}
		if( Double.isInfinite(r) )
			throw new RuntimeException("r is infinite");
		if( iter >= maxBoundIterations)
			throw new RuntimeException("Too many iterations when searching center region");

		boundEachRoot(-r,r,0,totalFound);

		int target;
		// search for roots below the center bound
		if( totalFound < numRoots && (target = sturm.countRealRoots(Double.NEGATIVE_INFINITY,-r)) > 0 ) {
			double upper = -r;
			double width = r;

			iter = 0;
			while( iter < maxBoundIterations && target > 0 ) {
				int N = sturm.countRealRoots(upper-width,upper);
				if( N != 0 ) {
					boundEachRoot(upper-width,upper,totalFound,N);
					target -= N;
					totalFound += N;
				}
				upper -= width;
				width = 2*width*width;
			}
			if( iter >= maxBoundIterations)
				throw new RuntimeException("Too many iterations when searching lower region");
		}

		if( totalFound < numRoots && (target = sturm.countRealRoots(r,Double.POSITIVE_INFINITY)) > 0 ) {
			double lower = r;
			double width = r;

			iter = 0;
			while( iter < maxBoundIterations && target > 0 ) {
				int N = sturm.countRealRoots(lower,lower+width);
				if( N != 0 ) {
					boundEachRoot(lower,lower+width,totalFound,N);
					target -= N;
					totalFound += N;
				}
				lower += width;
				width = 2*width*width;
			}
			if( iter >= maxBoundIterations)
				throw new RuntimeException("Too many iterations when searching upper region");
		}
	}
1095985
function( roots, fn, directed ){
      directed = arguments.length === 1 && !$$.is.fn(fn) ? fn : directed;
      fn = $$.is.fn(fn) ? fn : function(){};
      var cy = this._private.cy;
      var v = $$.is.string(roots) ? this.filter(roots) : roots;
      var S = [];
      var connectedNodes = [];
      var connectedBy = {};
      var id2depth = {};
      var discovered = {};
      var j = 0;
      var found;
      var edges = this.edges();
      var nodes = this.nodes();

      // push v
      for( var i = 0; i < v.length; i++ ){
        if( v[i].isNode() ){
          S.push( v[i] );

          connectedNodes.push( v[i] );
          id2depth[ v[i].id() ] = 0;
        }
      }

      while( S.length !== 0 ){
        var v = S.pop();

        if( !discovered[ v.id() ] ){
          discovered[ v.id() ] = true;

          var depth = id2depth[ v.id() ];

          var ret = fn.call(v, j++, depth);

          if( ret === true ){
            found = v;
            break;
          }

          if( ret === false ){
            break;
          }

          var vwEdges = v.connectedEdges(directed ? '[source = "' + v.id() + '"]' : undefined).intersect( edges );
          
          for( var i = 0; i < vwEdges.length; i++ ){
            var e = vwEdges[i];
            var w = e.connectedNodes('[id != "' + v.id() + '"]').intersect( nodes );

            if( w.length !== 0 && !discovered[ w.id() ] ){
              w = w[0];

              S.push( w );

              id2depth[ w.id() ] = id2depth[ v.id() ] + 1;

              connectedNodes.push( w );
              connectedBy[ w.id() ] = e;
            }
          }
        }
      }

      var connectedEles = [];

      for( var i = 0; i < connectedNodes.length; i++ ){
        var node = connectedNodes[i];
        var edge = connectedBy[ node.id() ];

        if( edge ){
          connectedEles.push( edge );
        }

        connectedEles.push( node );
      }

      return {
        path: new $$.Collection( cy, connectedEles ),
        found: new $$.Collection( cy, found )
      }
    }
490077
function( roots, fn, directed ){
      directed = arguments.length === 1 && !$$.is.fn(fn) ? fn : directed;
      fn = $$.is.fn(fn) ? fn : function(){};
      var cy = this._private.cy;
      var v = $$.is.string(roots) ? this.filter(roots) : roots;
      var Q = [];
      var connectedEles = [];
      var connectedFrom = {};
      var id2depth = {};
      var V = {};
      var j = 0;
      var found;
      var nodes = this.nodes();
      var edges = this.edges();

      // enqueue v
      for( var i = 0; i < v.length; i++ ){
        if( v[i].isNode() ){
          Q.unshift( v[i] );
          V[ v[i].id() ] = true; 

          connectedEles.push( v[i] );
          id2depth[ v[i].id() ] = 0;
        }
      }

      while( Q.length !== 0 ){
        var v = Q.shift();
        var depth = id2depth[ v.id() ];
        var ret = fn.call(v, j++, depth);

        if( ret === true ){
          found = v;
          break;
        }

        if( ret === false ){
          break;
        }

        var vwEdges = v.connectedEdges(directed ? '[source = "' + v.id() + '"]' : undefined).intersect( edges );
        for( var i = 0; i < vwEdges.length; i++ ){
          var e = vwEdges[i];
          var w = e.connectedNodes('[id != "' + v.id() + '"]').intersect( nodes );

          if( w.length !== 0 && !V[ w.id() ] ){
            w = w[0];

            Q.push( w );
            V[ w.id() ] = true;

            id2depth[ w.id() ] = id2depth[ v.id() ] + 1;

            connectedEles.push( w );
            connectedEles.push( e );
          }
        }
        
      }

      return {
        path: new $$.Collection( cy, connectedEles ),
        found: new $$.Collection( cy, found )
      };
    }
1065423
private void createEdge(Node fromNode, ControlFlowGraph.Branch branch,
      Node toNode) {
    cfg.createNode(fromNode);
    cfg.createNode(toNode);
    cfg.connectIfNotFound(fromNode, branch, toNode);
  }
1076023
public static <N extends AbstractDTNode<?, ?, ?, N>> Iterator<N> nodeIterator(N root) {
        return new NodeIterator<>(root);
    }
751879
public static Weighted<Arborescence<Node>> getMaxArborescence(WeightedGraph graph, Node root) {
        // remove all edges incoming to `root`. resulting arborescence is then forced to be rooted at `root`.
        return getMaxArborescence(graph.filterEdges(not(DirectedEdge.hasDestination(root))));
    }
938999
public static int getEdgeKey(Graph graph, int edgeId, int node, boolean reverse) {
        EdgeIteratorState edgeIteratorState = graph.getEdgeIteratorState(edgeId, node);
        return GHUtility.createEdgeKey(edgeIteratorState.getBaseNode(), edgeIteratorState.getAdjNode(), edgeId, reverse);
    }
1075858
public static <T> Stream<T> streamC(T root, Function<? super T, ? extends Collection<T>> edges)
    {
        return StreamSupport.stream(spliterator(root, (y)->edges.apply(y).stream()), false);
    }
605550
public void addEdge(int index, ReuseEdge<S, I, O> edge) {
        this.edges[index] = edge;
    }
1212531
public static <N extends AbstractDTNode<?, ?, ?, N>> Iterator<N> innerNodeIterator(N root) {
        return Iterators.filter(nodeIterator(root), n -> !n.isLeaf());
    }
304636
public void write(Tree<?, ?> tree) throws IOException {
        this.writer.append("digraph G"); //$NON-NLS-1$
        this.writer.append(Integer.toString(this.graphIndex++));
        this.writer.append(" {\n"); //$NON-NLS-1$

        if (tree != null) {
            // Write the node attributes
            Iterator<? extends TreeNode<?, ?>> iterator = tree.broadFirstIterator();
            TreeNode<?, ?> node;
            int dataCount;
            while (iterator.hasNext()) {
                node = iterator.next();
                dataCount = node.getUserDataCount();
                final String name = "NODE" + Integer.toHexString(System.identityHashCode(node)); //$NON-NLS-1$
                final String label = Integer.toString(dataCount);

                this.writer.append("\t"); //$NON-NLS-1$
                this.writer.append(name);
                this.writer.append(" [label=\""); //$NON-NLS-1$
                this.writer.append(label);
                this.writer.append("\"]\n"); //$NON-NLS-1$
            }

            this.writer.append("\n"); //$NON-NLS-1$

            // Write the node links
            iterator = tree.broadFirstIterator();
            Class<? extends Enum<?>> partitionType;
            TreeNode<?, ?> child;
            String childName;
            while (iterator.hasNext()) {
                node = iterator.next();
                final String name = "NODE" + Integer.toHexString(System.identityHashCode(node)); //$NON-NLS-1$
                if (!node.isLeaf()) {
                    partitionType = node.getPartitionEnumeration();
                    final int childCount = node.getChildCount();
                    for (int i = 0; i < childCount; ++i) {
                        child = node.getChildAt(i);
                        if (child != null) {
                            childName = "NODE" + Integer.toHexString(System.identityHashCode(child)); //$NON-NLS-1$
                            final String label;
                            if (partitionType != null) {
                                label = partitionType.getEnumConstants()[i].name();
                            } else {
                                label = Integer.toString(i);
                            }
                            this.writer.append("\t"); //$NON-NLS-1$
                            this.writer.append(name);
                            this.writer.append("->"); //$NON-NLS-1$
                            this.writer.append(childName);
                            this.writer.append(" [label=\""); //$NON-NLS-1$
                            this.writer.append(label);
                            this.writer.append("\"]\n"); //$NON-NLS-1$
                        }
                    }
                }
            }
        }

        this.writer.append("}\n\n"); //$NON-NLS-1$
    }
521926
public boolean isConnectedInDirection(
      DiGraphNode<N, E> dNode1,
      Predicate<E> edgeMatcher,
      DiGraphNode<N, E>  dNode2) {
    // Verify the nodes.
    List<DiGraphEdge<N, E>> outEdges = dNode1.getOutEdges();
    int outEdgesLen = outEdges.size();
    List<DiGraphEdge<N, E>> inEdges = dNode2.getInEdges();
    int inEdgesLen = inEdges.size();
    // It is possible that there is a large assymmetry between the nodes, so pick the direction
    // to search based on the shorter list since the edge lists should be symmetric.
    if (outEdgesLen < inEdgesLen) {
      for (int i = 0; i < outEdgesLen; i++) {
        DiGraphEdge<N, E> outEdge = outEdges.get(i);
        if (outEdge.getDestination() == dNode2
            && edgeMatcher.apply(outEdge.getValue())) {
          return true;
        }
      }
    } else {
      for (int i = 0; i < inEdgesLen; i++) {
        DiGraphEdge<N, E> inEdge = inEdges.get(i);
        if (inEdge.getSource() == dNode1
            && edgeMatcher.apply(inEdge.getValue())) {
          return true;
        }
      }
    }

    return false;
  }
1044767
public DTMIterator createDTMIterator(int node)
  {
    // DescendantIterator iter = new DescendantIterator();
    DTMIterator iter = new org.apache.xpath.axes.OneStepIteratorForward(Axis.SELF);
    iter.setRoot(node, this);
    return iter;
    // return m_dtmManager.createDTMIterator(node);
  }
1229819
def write_edges (self):
        
        for node in self.nodes.values():
            if node["parent_url"] in self.nodes:
                self.write_edge(node)
        self.flush()