private void resetColors(IntContainer nodes) { nodes.forEach((IntProcedure) node -> colors.set(node, node)); }
private void resetColors(IntContainer nodes) { nodes.forEach((IntProcedure) node -> colors.set(node, node)); }
@Override public void forEachRelationship(int nodeId, Direction direction, RelationshipConsumer consumer) { final IntContainer intCursors = graph.get(nodeId); if (null == intCursors) { return; } intCursors.forEach((IntProcedure) t -> consumer.accept(nodeId, t, -1)); }
@Override public void forEachRelationship(int nodeId, Direction direction, RelationshipConsumer consumer) { final IntContainer intCursors = graph.get(nodeId); if (null == intCursors) { return; } intCursors.forEach((IntProcedure) t -> consumer.accept(nodeId, t, -1)); }
for (Future<IntContainer> future : futures) { try { future.get().forEach((IntProcedure) ret::add); } catch (ExecutionException ee) { error = Exceptions.chain(error, ee.getCause());
for (Future<IntContainer> future : futures) { try { future.get().forEach((IntProcedure) ret::add); } catch (ExecutionException ee) { error = Exceptions.chain(error, ee.getCause());
/** * multistep coloring algorithm task * * @param nodes nodes to process * @return container with nodes which must be processed in the next step */ private IntContainer msColorTask(IntContainer nodes) { final IntStack levelQueue = new IntStack(nodes.size()); nodes.forEach((IntProcedure) node -> { final int nodeColor = colors.get(node); final boolean[] change = {false}; graph.forEachRelationship(node, Direction.OUTGOING, (sourceNodeId, targetNodeId, relationId) -> { if (cas(targetNodeId, nodeColor)) { if (!visited.get(targetNodeId)) { visited.set(targetNodeId); levelQueue.push(targetNodeId); change[0] = true; } } return true; }); if (change[0] && !visited.get(node)) { levelQueue.push(node); visited.set(node); } }); return levelQueue; }
/** * multistep coloring algorithm task * * @param nodes nodes to process * @return container with nodes which must be processed in the next step */ private IntContainer msColorTask(IntContainer nodes) { final IntStack levelQueue = new IntStack(nodes.size()); nodes.forEach((IntProcedure) node -> { final int nodeColor = colors.get(node); final boolean[] change = {false}; graph.forEachRelationship(node, Direction.OUTGOING, (sourceNodeId, targetNodeId, relationId) -> { if (cas(targetNodeId, nodeColor)) { if (!visited.get(targetNodeId)) { visited.set(targetNodeId); levelQueue.push(targetNodeId); change[0] = true; } } return true; }); if (change[0] && !visited.get(node)) { levelQueue.push(node); visited.set(node); } }); return levelQueue; }