/** * 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; }
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 double getStdDev(int hour) { if(hourStdDevCache != null && hourStdDevCache.containsKey(hour)) return hourStdDevCache.get(hour);
double weight = graph.weightOf(s, t); int localCommunity = localCommunities[t]; if (communityWeights.containsKey(localCommunity)) { communityWeights.addTo(localCommunity, weight); } else {
if (cost.containsKey(t)) { cost.put(t, w); queue.update(t);
if (cost.containsKey(t)) { cost.put(t, w); queue.update(t);