private static double getCost(List<Location> path, AccessibilityGraphImpl graph) {
    double cost = 0;

    for (int i = 0; i < path.size() - 1; i++) {
      cost += graph.getShortestPathLength(path.get(i), path.get(i + 1));
    }

    return cost;
  }
 private double getCost(Location[] array, int i, int j) {
   return graph.getShortestPathLength(array[i], array[j]);
 }