PathFinding { @Procedure @Description("apoc.algo.aStar(startNode, endNode, 'KNOWS|<WORKS_WITH|IS_MANAGER_OF>', {weight:'dist',default:10," + "x:'lon',y:'lat'}) YIELD path, weight - run A* with relationship property name as cost function") public Stream<WeightedPathResult> aStarConfig( @Name("startNode") Node startNode, @Name("endNode") Node endNode, @Name("relationshipTypesAndDirections") String relTypesAndDirs, @Name("config") Map<String, Object> config) { config = config == null ? Collections.emptyMap() : config; String relationshipCostPropertyKey = config.getOrDefault("weight", "distance").toString(); double defaultCost = ((Number) config.getOrDefault("default", Double.MAX_VALUE)).doubleValue(); String latPropertyName = config.getOrDefault("y", "latitude").toString(); String lonPropertyName = config.getOrDefault("x", "longitude").toString(); PathFinder<WeightedPath> algo = GraphAlgoFactory.aStar( new BasicEvaluationContext(tx, db), buildPathExpander(relTypesAndDirs), CommonEvaluators.doubleCostEvaluator(relationshipCostPropertyKey, defaultCost), CommonEvaluators.geoEstimateEvaluator(latPropertyName, lonPropertyName)); return WeightedPathResult.streamWeightedPathResult(startNode, endNode, algo); }  @Procedure @Description("apoc.algo.aStar(startNode, endNode, 'KNOWS|<WORKS_WITH|IS_MANAGER_OF>', 'distance','lat','lon') " + "YIELD path, weight - run A* with relationship property name as cost function") Stream<WeightedPathResult> aStar(
            @Name("startNode") Node startNode,
            @Name("endNode") Node endNode,
            @Name("relationshipTypesAndDirections") String relTypesAndDirs,
            @Name("weightPropertyName") String weightPropertyName,
            @Name("latPropertyName") String latPropertyName,
            @Name("lonPropertyName") String lonPropertyName); @Procedure @Description("apoc.algo.aStar(startNode, endNode, 'KNOWS|<WORKS_WITH|IS_MANAGER_OF>', {weight:'dist',default:10," + "x:'lon',y:'lat'}) YIELD path, weight - run A* with relationship property name as cost function") Stream<WeightedPathResult> aStarConfig(
            @Name("startNode") Node startNode,
            @Name("endNode") Node endNode,
            @Name("relationshipTypesAndDirections") String relTypesAndDirs,
            @Name("config") Map<String, Object> config); @Procedure @Description("apoc.algo.dijkstra(startNode, endNode, 'KNOWS|<WORKS_WITH|IS_MANAGER_OF>', 'distance', defaultValue, numberOfWantedResults) YIELD path," + " weight - run dijkstra with relationship property name as cost function") Stream<WeightedPathResult> dijkstra(
            @Name("startNode") Node startNode,
            @Name("endNode") Node endNode,
            @Name("relationshipTypesAndDirections") String relTypesAndDirs,
            @Name("weightPropertyName") String weightPropertyName,
            @Name(value = "defaultWeight", defaultValue = "NaN") double defaultWeight,
            @Name(value = "numberOfWantedPaths", defaultValue = "1") long numberOfWantedPaths); @Procedure @Description("apoc.algo.allSimplePaths(startNode, endNode, 'KNOWS|<WORKS_WITH|IS_MANAGER_OF>', 5) YIELD path, " + "weight - run allSimplePaths with relationships given and maxNodes") Stream<PathResult> allSimplePaths(
            @Name("startNode") Node startNode,
            @Name("endNode") Node endNode,
            @Name("relationshipTypesAndDirections") String relTypesAndDirs,
            @Name("maxNodes") long maxNodes); @Procedure(deprecatedBy = "apoc.algo.dijkstra") @Description("apoc.algo.dijkstraWithDefaultWeight(startNode, endNode, 'KNOWS|<WORKS_WITH|IS_MANAGER_OF>', " + "'distance', 10) YIELD path, weight - run dijkstra with relationship property name as cost function" + " and a default weight if the property does not exist") @Deprecated Stream<WeightedPathResult> dijkstraWithDefaultWeight(
            @Name("startNode") Node startNode,
            @Name("endNode") Node endNode,
            @Name("relationshipTypesAndDirections") String relTypesAndDirs,
            @Name("weightPropertyName") String weightPropertyName,
            @Name("defaultWeight") double defaultWeight); @Context
    public GraphDatabaseService db; @Context
    public Transaction tx; }
@Test public void testAStarConfig() { db.executeTransactionally(SETUP_GEO); testResult(db, "MATCH (from:City {name:'München'}), (to:City {name:'Hamburg'}) " + "CALL apoc.algo.aStarConfig(from, to, 'DIRECT', {weight:'dist',y:'lat', x:'lon',default:100}) yield path, weight " + "RETURN path, weight" , r -> assertAStarResult(r) ); }