private void buildPropagationPath() { byte[] state = new byte[types.length]; int[] path = new int[types.length]; int pathSize = 0; IntStack stack = new IntStack(); for (int i = 0; i < graph.size(); ++i) { if (graph.incomingEdgesCount(i) == 0 && types[i] != null) { stack.push(i); } } while (!stack.isEmpty()) { int node = stack.pop(); if (state[node] == FRESH) { state[node] = VISITING; stack.push(node); for (int successor : graph.outgoingEdges(node)) { if (state[successor] == FRESH) { stack.push(successor); } } } else if (state[node] == VISITING) { path[pathSize++] = node; state[node] = VISITED; } } propagationPath = Arrays.copyOf(path, pathSize); }
/** * Pushes all elements from another container to the top of the stack. */ public int pushAll(IntContainer container) { return addAll(container); }
private boolean compute(int startNode) { clearPaths(); stack.clear(); queue.clear(); Arrays.fill(sigma, 0); while (!queue.isEmpty() && running()) { int node = queue.removeFirst(); stack.push(node); graph.forEachRelationship(node, direction, (source, target, relationId) -> { if (distance[target] < 0) { }); while (!stack.isEmpty() && running()) { final int node = stack.pop(); if (null == paths[node]) { continue;
/** * Vararg-signature method for pushing elements at the top of the stack. * <p> * <b>This method is handy, but costly if used in tight loops (anonymous array * passing)</b> * </p> */ /* */ public final void push(int... elements) { push(elements, 0, elements.length); }
connectedComponents[nodeId] = dfsNum; int lowPoint = dfsNum; open.push(nodeId); final int sz = edgeStack.size(); graph.forEachRelationship(nodeId, Direction.OUTGOING, (sourceNodeId, targetNodeId, relationId) -> { edgeStack.push(targetNodeId); return true; }); while (edgeStack.size() > sz) { int w = edgeStack.pop(); int d = connectedComponents[w]; if (d == -1) { int element; do { element = open.pop(); connectedComponents[element] = setCount; elementCount++;
while (!queue.isEmpty()) { int node = queue.removeFirst(); stack.push(node); graph.forEachRelationship(node, direction, (source, target, relationId) -> { if (distance[target] < 0) { while (!stack.isEmpty()) { int node = stack.pop(); paths.forEach(node, v -> { delta[v] += (double) sigma[v] / (double) sigma[node] * (delta[node] + 1.0);
/** * Collect all words from a phrase. */ private void appendWords(IntStack words, IntStack offsets, PhraseCandidate p) { final int start = words.size(); final int [] phraseIndices = p.cluster.phrases.get(0); final short [] tokenTypes = context.allWords.type; for (int i = 0; i < phraseIndices.length; i += 2) { for (int j = phraseIndices[i]; j <= phraseIndices[i + 1]; j++) { final int termIndex = sb.input.get(j); if (!TokenTypeUtils.isCommon(tokenTypes[termIndex])) { words.push(termIndex); } } } offsets.push(start, words.size() - start); }
/** * pop head of the popStack * * @return head of the popStack */ public int pop() { return popStack().pop(); }
@Override void evaluateNode(final int nodeId) { IntStack nodes = this.nodes; graph.forEachRelationship(nodeId, D, (s, t, r) -> { if (t > s) { nodes.add(t); } return running(); }); while (!nodes.isEmpty()) { final int node = nodes.pop(); graph.forEachRelationship(node, D, (s, t, r) -> { if (t > s && graph.exists(t, nodeId, D)) { emit(nodeId, s, t); } return running(); }); } } }
/** * Initializes the counters for the a token image. */ private void resetForNewTokenImage(final int [] documentIndexesArray, final int [] tokenImagesOrder, final BitSet fieldIndices, IntStack wordDocuments, int i) { fieldIndices.clear(); wordDocuments.clear(); if (documentIndexesArray[tokenImagesOrder[i + 1]] >= 0) { wordDocuments.push(documentIndexesArray[tokenImagesOrder[i + 1]]); } }
private void postVisit(int nodeId) { if (boundaries.peek() == index[nodeId]) { boundaries.pop(); int elementCount = 0; int element; do { element = stack.pop(); connectedComponents[element] = nodeId; visited.put(element); elementCount++; } while (element != nodeId); minSetSize = Math.min(minSetSize, elementCount); maxSetSize = Math.max(maxSetSize, elementCount); setCount++; } }
private boolean compute(int nodeId) { if (!running()) { return false; } if (index[nodeId] != -1) { return true; } push(Action.VISIT, nodeId); while (!todo.isEmpty()) { final int action = todo.pop(); final int node = todo.pop(); if (action == Action.VISIT.code) { visit(node); } else if (action == Action.VISITEDGE.code) { visitEdge(node); } else { postVisit(node); } } getProgressLogger().logProgress((double) nodeId / (nodeCount - 1)); return true; }
/** * check if the popStack is empty * * @return */ public boolean isEmpty() { return popStack().isEmpty(); }