/** * Add a new target node to the heuristic. * @param target location to be added. */ public void addTargetNodeToHeuristic(Point2D target) { Preconditions.checkNotNull(target, "The target node may not be null"); synchronized (lock) { for (Entry<Point2D, ObjectDoubleMap<Point2D>> entry : heuristicMap.entrySet()) { if (!entry.getValue().containsKey(target)) { Point2D source = entry.getKey(); double dist = calculateWeight(source, target); entry.getValue().put(target, dist); } } } }
private ObjectDoubleMap<Point2D> calculateHeuristicForSource(Point2D source, List<ICity> cities) { ObjectDoubleMap<Point2D> distance = new ObjectDoubleScatterMap<>(); for (ICity city : cities) { final Point2D coordinates = city.getCoordinates(); double dist = calculateWeight(source, coordinates); distance.put(coordinates, dist); } return distance; } @VisibleForTesting