public IntCollection getValues() { return counts.keys(); }
public int getN() { return counts.size(); }
public double getCount(int value) { return counts.get(value); }
private boolean updateCosts(final int source, final int target, final double newCost, final double heuristic) { final double oldCost = gCosts.getOrDefault(target, Double.MAX_VALUE); if (newCost < oldCost) { gCosts.put(target, newCost); fCosts.put(target, newCost + heuristic); path.put(target, source); return oldCost < Double.MAX_VALUE; } return false; }
public double getStdDev(int hour) { if(hourStdDevCache != null && hourStdDevCache.containsKey(hour)) return hourStdDevCache.get(hour); if(hourCount.get(hour) == 0) return Double.NaN; double binCount = hourCount.get(hour); double tmpBinCount = 0.0; double meanSquaredSum = squaredSum / hourCount.get(hour); hourStdDevCache.put(hour, stdDev);
double weight = graph.weightOf(s, t); int localCommunity = localCommunities[t]; if (communityWeights.containsKey(localCommunity)) { communityWeights.addTo(localCommunity, weight); } else { communityWeights.put(localCommunity, weight); communitiesInOrder[communityCount[0]++] = localCommunity; }); final double w = communityWeights.get(currentCommunity); sTot[currentCommunity] -= ki[node]; sIn[currentCommunity] -= 2 * (w + nodeWeights.weightOf(node)); double wic = communityWeights.get(community); final double g = wic / m2 - sTot[community] * ki[node] / m22; if (g > bestGain) {
/** * update cost map */ private UpdateResult updateCosts(int source, int target, double newCosts) { double oldCosts = costs.getOrDefault(target, Double.MAX_VALUE); if (oldCosts == Double.MAX_VALUE) { if (!costs.containsKey(target)) { costs.put(target, newCosts); path.put(target, source); return UpdateResult.NO_PREVIOUS_COSTS; } } if (newCosts < oldCosts) { costs.put(target, newCosts); path.put(target, source); return UpdateResult.UPDATED_COST; } return UpdateResult.COST_NOT_COMPETITIVE; }
public ShortestPathDijkstra compute(long startNode, long goalNode, Direction direction) { reset(); int node = graph.toMappedNodeId(startNode); int goal = graph.toMappedNodeId(goalNode); costs.put(node, 0.0); queue.add(node, 0.0); run(goal, direction); if (!path.containsKey(goal)) { return this; } totalCost = costs.get(goal); int last = goal; while (last != PATH_END) { finalPath.addFirst(last); finalPathCosts.addFirst(costs.get(last)); last = path.getOrDefault(last, PATH_END); } // destroy costs and path to remove the data for nodes that are not part of the graph // since clear never downsizes the buffer array costs.release(); path.release(); return this; }
costs.clear(); queue.clear(); path.clear(); visited.clear(); costs.put(source, 0.0); queue.add(source, 0.0); Arrays.fill(depth, 0); double costs = this.costs.getOrDefault(node, Double.MAX_VALUE); graph.forEachRelationship( node,
/** * compute the shortest paths from startNode * * @param startNode the start node id (original neo4j id) * @return itself */ public ShortestPaths compute(long startNode) { graph.forEachNode(node -> { costs.put(node, Double.POSITIVE_INFINITY); return true; }); final int nodeId = graph.toMappedNodeId(startNode); costs.put(nodeId, 0d); queue.add(nodeId, 0d); run(); return this; }
sigma.clear(); paths.clear(); delta.clear(); sigma.put(startNodeId, 1); distance[startNodeId] = 0; if (null != intCursors) { intCursors.forEach((Consumer<? super IntCursor>) c -> { delta.addTo(c.value, (double) sigma.getOrDefault(c.value, 0) / (double) sigma.getOrDefault(node, 0) * (delta.getOrDefault(node, 0) + 1.0)); }); centrality.add(node, f * (delta.getOrDefault(node, 0)));
@Override protected double cost(final int element) { return costs.getOrDefault(element, defaultCost); }
public double getCount(int value) { return counts.get(value); }
private boolean updateCosts(final int source, final int target, final double newCost, final double heuristic) { final double oldCost = gCosts.getOrDefault(target, Double.MAX_VALUE); if (newCost < oldCost) { gCosts.put(target, newCost); fCosts.put(target, newCost + heuristic); path.put(target, source); return oldCost < Double.MAX_VALUE; } return false; }
private void updateCosts(int source, int target, double newCosts) { if (costs.containsKey(target)) { if (newCosts < costs.getOrDefault(target, Double.MAX_VALUE)) { costs.put(target, newCosts); path.put(target, source); queue.update(target); } } else { if (newCosts < costs.getOrDefault(target, Double.MAX_VALUE)) { costs.put(target, newCosts); path.put(target, source); queue.add(target, newCosts); } } }
public ShortestPathDijkstra compute(long startNode, long goalNode, Direction direction) { reset(); int node = graph.toMappedNodeId(startNode); int goal = graph.toMappedNodeId(goalNode); costs.put(node, 0.0); queue.add(node, 0.0); run(goal, direction); if (!path.containsKey(goal)) { return this; } totalCost = costs.get(goal); int last = goal; while (last != PATH_END) { finalPath.addFirst(last); finalPathCosts.addFirst(costs.get(last)); last = path.getOrDefault(last, PATH_END); } // destroy costs and path to remove the data for nodes that are not part of the graph // since clear never downsizes the buffer array costs.release(); path.release(); return this; }
costs.clear(); queue.clear(); path.clear(); visited.clear(); costs.put(source, 0.0); queue.add(source, 0.0); Arrays.fill(depth, 1); double costs = this.costs.getOrDefault(node, Double.MAX_VALUE); graph.forEachRelationship( node,
/** * compute the shortest paths from startNode * * @param startNode the start node id (original neo4j id) * @return itself */ public ShortestPaths compute(long startNode) { graph.forEachNode(node -> { costs.put(node, Double.POSITIVE_INFINITY); return true; }); final int nodeId = graph.toMappedNodeId(startNode); costs.put(nodeId, 0d); queue.add(nodeId, 0d); run(); return this; }
sigma.clear(); paths.clear(); delta.clear(); sigma.put(startNodeId, 1); distance[startNodeId] = 0; if (null != intCursors) { intCursors.forEach((Consumer<? super IntCursor>) c -> { delta.addTo(c.value, (double) sigma.getOrDefault(c.value, 0) / (double) sigma.getOrDefault(node, 0) * (delta.getOrDefault(node, 0) + 1.0)); }); centrality.add(node, f * (delta.getOrDefault(node, 0)));