@Override protected double cost(final int element) { return costs.getOrDefault(element, defaultCost); }
@Override protected double cost(final int element) { return costs.getOrDefault(element, defaultCost); }
private boolean updateCosts(int source, int target, double newCosts) { double oldCosts = costs.getOrDefault(target, Double.MAX_VALUE); if (newCosts < oldCosts) { costs.put(target, newCosts); path.put(target, source); return oldCosts < Double.MAX_VALUE; } return false; }
/** * update cost map */ private boolean updateCosts(int source, int target, double newCosts) { double oldCosts = costs.getOrDefault(target, Double.MAX_VALUE); if (newCosts < oldCosts) { costs.put(target, newCosts); path.put(target, source); return oldCosts < Double.MAX_VALUE; } return false; }
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 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); } } }
private void run() { while (!queue.isEmpty() && running()) { final int node = queue.pop(); double sourceCosts = this.costs.getOrDefault(node, Double.POSITIVE_INFINITY); // scan ALL relationships graph.forEachRelationship( node, Direction.OUTGOING, (source, target, relId, weight) -> { // relax final double targetCosts = this.costs.getOrDefault(target, Double.POSITIVE_INFINITY); if (weight + sourceCosts < targetCosts) { costs.put(target, weight + sourceCosts); queue.set(target, weight + sourceCosts); } return true; }); progressLogger.logProgress((double) node / (nodeCount - 1)); } }
private void run() { while (!queue.isEmpty() && running()) { final int node = queue.pop(); double sourceCosts = this.costs.getOrDefault(node, Double.POSITIVE_INFINITY); // scan ALL relationships graph.forEachRelationship( node, Direction.OUTGOING, (source, target, relId, weight) -> { // relax final double targetCosts = this.costs.getOrDefault(target, Double.POSITIVE_INFINITY); if (weight + sourceCosts < targetCosts) { costs.put(target, weight + sourceCosts); queue.set(target, targetCosts); } return true; }); progressLogger.logProgress((double) node / (nodeCount - 1)); } }
/** * 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 run(int goal, Direction direction) { while (!queue.isEmpty() && running()) { int node = queue.pop(); if (node == goal) { return; } visited.set(node); double costs = this.costs.getOrDefault(node, Double.MAX_VALUE); graph.forEachRelationship( node, direction, (source, target, relId, weight) -> { updateCosts(source, target, weight + costs); return true; }); progressLogger.logProgress((double) node / (nodeCount - 1)); } }
private void run(int goal, Direction direction) { while (!queue.isEmpty() && running()) { int node = queue.pop(); if (node == goal) { return; } visited.set(node); double costs = this.costs.getOrDefault(node, Double.MAX_VALUE); graph.forEachRelationship( node, direction, (source, target, relId, weight) -> { boolean oldCostChanged = updateCosts(source, target, weight + costs); if (!visited.get(target)) { if (oldCostChanged) { queue.update(target); } else { queue.add(target, 0); } } return true; }); progressLogger.logProgress((double) node / (nodeCount - 1)); } }
if (w < cost.getOrDefault(t, Double.MAX_VALUE)) { cost.put(t, w); queue.add(t, -1.0);
double costs = this.costs.getOrDefault(node, Double.MAX_VALUE); graph.forEachRelationship( node,
double costs = this.costs.getOrDefault(node, Double.MAX_VALUE); graph.forEachRelationship( node,
double currentNodeCost = this.gCosts.getOrDefault(currentNodeId, Double.MAX_VALUE); graph.forEachRelationship( currentNodeId,
double currentNodeCost = this.gCosts.getOrDefault(currentNodeId, Double.MAX_VALUE); graph.forEachRelationship( currentNodeId,
if (w < cost.getOrDefault(t, Double.MAX_VALUE)) { if (cost.containsKey(t)) { cost.put(t, w);
if (w < cost.getOrDefault(t, Double.MAX_VALUE)) { cost.put(t, w); queue.add(t, -1.0);
if (w < cost.getOrDefault(t, Double.MAX_VALUE)) { if (cost.containsKey(t)) { cost.put(t, w);