If the {@code nextSubgraphs} queue is empty, expands the graph frontier
of the next available vertex, if one exists, and the subgraphs reachable
from it to the queue.
199955
private void advance() {
        while (nextSubgraphs.isEmpty() && vertexIter.hasNext()) {
            Integer nextVertex = vertexIter.next();
            // Determine the set of vertices that are greater than this vertex
            Set<Integer> extension = new HashSet<Integer>();
            for (Integer v : g.getNeighbors(nextVertex))
                if (v > nextVertex)
                    extension.add(v);
            Set<Integer> subgraph = new HashSet<Integer>();
            subgraph.add(nextVertex);
            extendSubgraph(subgraph, extension, nextVertex);
        }
    }
234879
public void expandListParagraphs()
    {
        if (this.type != BlockType.ORDERED_LIST && this.type != BlockType.UNORDERED_LIST)
        {
            return;
        }
        Block outer = this.blocks, inner;
        boolean hasParagraph = false;
        while (outer != null && !hasParagraph)
        {
            if (outer.type == BlockType.LIST_ITEM)
            {
                inner = outer.blocks;
                while (inner != null && !hasParagraph)
                {
                    if (inner.type == BlockType.PARAGRAPH)
                    {
                        hasParagraph = true;
                    }
                    inner = inner.next;
                }
            }
            outer = outer.next;
        }
        if (hasParagraph)
        {
            outer = this.blocks;
            while (outer != null)
            {
                if (outer.type == BlockType.LIST_ITEM)
                {
                    inner = outer.blocks;
                    while (inner != null)
                    {
                        if (inner.type == BlockType.NONE)
                        {
                            inner.type = BlockType.PARAGRAPH;
                        }
                        inner = inner.next;
                    }
                }
                outer = outer.next;
            }
        }
    }
92612
private EdgeSet<T> addIfAbsent(int v) {
        S edges = getEdgeSet(v);
        if (edges == null) {
            edges = createEdgeSet(v);
            vertexToEdges.put(v, edges);
        }
        return edges;
    }
375421
private void growCluster(List<ChessboardCorner> corners, int seedIdx, ChessboardCornerGraph graph) {
		// open contains corner list indexes
		open.add(seedIdx);
		while( open.size > 0 ) {
			int cornerIdx = open.pop();
			Vertex v = vertexes.get(cornerIdx);

			// make sure it hasn't already been processed
			if( v.marked)
				continue;
			v.marked = true;

			// Create the node in the output cluster for this corner
			ChessboardCornerGraph.Node gn = graph.growCorner();
			c2n.data[cornerIdx] = gn.index;
			n2c.data[gn.index] = cornerIdx;
			gn.set(corners.get(cornerIdx));

			// Add to the open list all the edges which haven't been processed yet;
			for (int i = 0; i < v.connections.size(); i++) {
				Vertex dst = v.connections.get(i).dst;
				if( dst.marked)
					continue;
				open.add( dst.index );
			}
		}
	}
371528
public Next<Flow<T>> getOrCreateNext()
   {
      List<Node> nodeList = childNode.get("next");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new NextImpl<Flow<T>>(this, "next", childNode, nodeList.get(0));
      }
      return createNext();
   }
679933
def _get_connected_subgraphs(vertices, vertices_neighbours):
    
    remaining_vertices = set(vertices)
    subgraphs = []
    while remaining_vertices:
        subgraph = set(_dfs(remaining_vertices.pop(), vertices_neighbours))
        remaining_vertices.difference_update(subgraph)
        subgraphs.append(subgraph)

    return subgraphs
619685
function widthTraverse (graph, reachable, start, depth, hops, iter) {
  if(!start)
    throw new Error('Graphmitter#traverse: start must be provided')

  //var nodes = 1

  reachable[start] = reachable[start] == null ? 0 : reachable[start]

  var queue = [start] //{key: start, hops: depth}]
  iter = iter || function () {}
  while(queue.length) {
    var o = queue.shift()
    var h = reachable[o]
    var node = graph[o]
    if(node && (!hops || (h + 1 <= hops)))
      for(var k in node) {
        // If we have already been to this node by a shorter path,
        // then skip this node (this only happens when processing
        // a realtime edge)
        if(!(reachable[k] != null && reachable[k] < h + 1)) {
          if(false === iter(o, k, h + 1, reachable[k]))
            return reachable

          reachable[k] = h + 1
//          nodes ++
          queue.push(k)
        }
    }
  }

  return reachable
}
383670
def iterated_dominance_frontier(set, dom_tree)
      worklist = Set.new(set)
      result = Set.new(set)
      frontier = dominance_frontier(dom_tree)

      until worklist.empty?
        block = worklist.pop
        frontier[dom_tree[block]].each do |candidate|
          candidate_in_full_graph = self[candidate]
          unless result.include?(candidate_in_full_graph)
            result << candidate_in_full_graph
            worklist << candidate_in_full_graph
          end
        end
      end
      result
    end
1166417
def new_edge(self, node_a, node_b, cost=1):
        """"""

        # Verify that both nodes exist in the graph
        try:
            self.nodes[node_a]
        except KeyError:
            raise NonexistentNodeError(node_a)
        try:
            self.nodes[node_b]
        except KeyError:
            raise NonexistentNodeError(node_b)

        # Create the new edge
        edge_id = self.generate_edge_id()

        edge = {'id': edge_id,
                'vertices': (node_a, node_b),
                'cost': cost,
                'data': {}
        }

        self.edges[edge_id] = edge
        self.nodes[node_a]['edges'].append(edge_id)

        self._num_edges += 1

        return edge_id
530305
private void grow(int minCapacity) {
        int oldCapacity = queue.length;
        // Double size if small; else grow by 50%
        int newCapacity = oldCapacity + ((oldCapacity < 64) ?
                                         (oldCapacity + 2) :
                                         (oldCapacity >> 1));
        // overflow-conscious code
        if (newCapacity - MAX_ARRAY_SIZE > 0)
            newCapacity = hugeCapacity(minCapacity);
        queue = Arrays.copyOf(queue, newCapacity);
    }
285061
protected void addToQueue(double closestDistanceSq , KdTree.Node node , P target ) {

		if( !node.isLeaf() ) {
			Helper h;
			if( unused.isEmpty() ) {
				h = new Helper();
			} else {
				h = unused.remove( unused.size()-1 );
			}

			h.closestPossibleSq = closestDistanceSq;
			h.node = node;

			queue.add(h);
		} else {
			checkBestDistance(node, target);
		}
	}
452445
function dijkstra(graph, s) {
  const distance = {};
  const previous = {};
  const q = new PriorityQueue();
  // Initialize
  distance[s] = 0;
  graph.vertices.forEach(v => {
    if (v !== s) {
      distance[v] = Infinity;
    }
    q.insert(v, distance[v]);
  });

  let currNode;
  const relax = v => {
    const newDistance = distance[currNode] + graph.edge(currNode, v);
    if (newDistance < distance[v]) {
      distance[v] = newDistance;
      previous[v] = currNode;
      q.changePriority(v, distance[v]);
    }
  };
  while (!q.isEmpty()) {
    currNode = q.extract();
    graph.neighbors(currNode).forEach(relax);
  }
  return {
    distance,
    previous
  };
}
731283
public static int nvgraphExtractSubgraphByVertex(
        nvgraphHandle handle, 
        nvgraphGraphDescr descrG, 
        nvgraphGraphDescr subdescrG, 
        Pointer subvertices, 
        long numvertices)
    {
        return checkResult(nvgraphExtractSubgraphByVertexNative(handle, descrG, subdescrG, subvertices, numvertices));
    }
1215702
private boolean nextWithoutLimit() throws SQLException {
		if (maxRows > 0 && rowsFetched >= maxRows) {
			System.out.println("Reach max rows " + maxRows);
			return false;
		}

		if ((recordItr == null || !recordItr.hasNext()) && !emptyResultSet) {
			TSFetchResultsReq req = new TSFetchResultsReq(sql, fetchSize);

			try {
				TSFetchResultsResp resp = client.fetchResults(req);
				Utils.verifySuccess(resp.getStatus());
				if (!resp.hasResultSet) {
					emptyResultSet = true;
				} else {
					TSQueryDataSet tsQueryDataSet = resp.getQueryDataSet();
					List<RowRecord> records = Utils.convertRowRecords(tsQueryDataSet);
					recordItr = records.iterator();
				}
			} catch (TException e) {
				throw new SQLException("Cannot fetch result from server, because of network connection");
			}

		}
		if (emptyResultSet) {
			return false;
		}
		record = recordItr.next();
		// if(record.getDeltaObjectType() != null &&
		// record.getDeltaObjectType().equals(AGGREGATION_STR)){
		// if(columnInfo.containsKey(TIMESTAMP_STR)){
		// columnInfo.remove(TIMESTAMP_STR);
		// }
		// }

		rowsFetched++;
        // maxRows is a constraint that exists in parallel with the LIMIT&SLIMIT constraints,
        // so rowsFetched will increase whenever the row is fetched,
        // regardless of whether the row satisfies the LIMIT&SLIMIT constraints or not.

		return true;
	}
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;
    }
262613
private void addSuccessor(final int stackSize, final Label successor) {
        Edge b;
        // creates a new Edge object or reuses one from the shared pool
        synchronized (SIZE) {
            if (pool == null) {
                b = new Edge();
            } else {
                b = pool;
                // removes b from the pool
                pool = pool.poolNext;
            }
        }
        // adds the previous Edge to the list of Edges used by this MethodWriter
        if (tail == null) {
            tail = b;
        }
        b.poolNext = head;
        head = b;
        // initializes the previous Edge object...
        b.stackSize = stackSize;
        b.successor = successor;
        // ...and adds it to the successor list of the currentBlock block
        b.next = currentBlock.successors;
        currentBlock.successors = b;
    }
973933
private void stepClosest(KdTree.Node node , FastQueue<KdTreeResult> neighbors ) {

		if( node == null )
			return;

		checkBestDistance(node, neighbors);

		if( node.isLeaf() ) {
			return;
		}

		// select the most promising branch to investigate first
		KdTree.Node nearer,further;

		double splitValue = distance.valueAt((P)node.point, node.split );

		double targetAtSplit = distance.valueAt(target,node.split);
		if( targetAtSplit<= splitValue ) {
			nearer = node.left;
			further = node.right;
		} else {
			nearer = node.right;
			further = node.left;
		}

		stepClosest(nearer,neighbors);

		// See if it is possible for 'further' to contain a better node
		// Or if N matches have yet to be find, if it is possible to meet the maximum distance requirement
		double dx = splitValue - targetAtSplit;
		if( dx*dx <= mostDistantNeighborSq) {
			if( neighbors.size() < searchN || dx*dx < mostDistantNeighborSq) {
				stepClosest(further,neighbors);
			}
		}
	}