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); }
int entry = stack.pop();
/** * pop head of the popStack * * @return head of the popStack */ public int pop() { return popStack().pop(); }
public void endElement(String namespaceURI, String localName, String qName) throws SAXException { String pathAsString = path.toString(); if (triggers.containsKey(pathAsString)) { triggers.get(pathAsString).afterElement(localName, pathAsString, text.toString()); } this.path.setLength(pathSegments.pop()); text.setLength(0); }
/** * pop head of the popStack * * @return head of the popStack */ public int pop() { return popStack().pop(); }
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 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 void visitEdge(int nodeId) { if (index[nodeId] == -1) { push(Action.VISIT, nodeId); } else if (!visited.contains(nodeId)) { while (index[nodeId] < boundaries.peek()) { boundaries.pop(); } } }
private void visitEdge(int nodeId) { if (index[nodeId] == -1) { push(Action.VISIT, nodeId); } else if (!visited.contains(nodeId)) { while (index[nodeId] < boundaries.peek()) { boundaries.pop(); } } }
private void relax(int nodeId) { IntHashSet connected = new IntHashSet(); int w; do { w = stack.pop(); onStack.clear(w); connected.add(w); } while (w != nodeId); connectedComponents.add(connected); int size = connected.size(); if (size < minSetSize) { minSetSize = size; } if (size > maxSetSize) { maxSetSize = size; } }
private void relax(int nodeId) { IntHashSet connected = new IntHashSet(); int w; do { w = stack.pop(); onStack.clear(w); connected.add(w); } while (w != nodeId); connectedComponents.add(connected); int size = connected.size(); if (size < minSetSize) { minSetSize = size; } if (size > maxSetSize) { maxSetSize = size; } }
private void relax(int nodeId) { IntHashSet connected = new IntHashSet(); int w; do { w = stack.pop(); onStack.clear(w); connected.add(w); } while (w != nodeId); processSCC(nodeId, connected); }
private void relax(int nodeId) { IntHashSet connected = new IntHashSet(); int w; do { w = stack.pop(); onStack.clear(w); connected.add(w); } while (w != nodeId); processSCC(nodeId, connected); }
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; }
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; }
/** * Compute in-link count for each state. */ private IntIntHashMap computeInlinkCount(final FSA fsa) { IntIntHashMap inlinkCount = new IntIntHashMap(); BitSet visited = new BitSet(); IntStack nodes = new IntStack(); nodes.push(fsa.getRootNode()); while (!nodes.isEmpty()) { final int node = nodes.pop(); if (visited.get(node)) continue; visited.set(node); for (int arc = fsa.getFirstArc(node); arc != 0; arc = fsa.getNextArc(arc)) { if (!fsa.isArcTerminal(arc)) { final int target = fsa.getEndNode(arc); inlinkCount.putOrAdd(target, 1, 1); if (!visited.get(target)) nodes.push(target); } } } return inlinkCount; }
@Override public void run() { final IntStack nodes = new IntStack(); final TerminationFlag flag = getTerminationFlag(); final int[] head = new int[1]; while ((head[0] = queue.getAndIncrement()) < nodeCount) { graph.forEachRelationship(head[0], direction, (s, t, r) -> { if (t > s) { nodes.push(t); } return flag.running(); }); while (!nodes.isEmpty()) { final int node = nodes.pop(); graph.forEachRelationship(node, direction, (s, t, r) -> { if (t > s && graph.exists(t, head[0], direction)) { triangles.incrementAndGet(head[0]); triangles.incrementAndGet(s); triangles.incrementAndGet(t); triangleCount.increment(); } return flag.running(); }); } getProgressLogger().logProgress(visitedNodes.incrementAndGet(), nodeCount); } } }
@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(); }); } } }
@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(); }); } } }