PathFinding { @Procedure @Description("apoc.algo.allSimplePaths(startNode, endNode, 'KNOWS|<WORKS_WITH|IS_MANAGER_OF>', 5) YIELD path, " + "weight - run allSimplePaths with relationships given and maxNodes") public Stream<PathResult> allSimplePaths( @Name("startNode") Node startNode, @Name("endNode") Node endNode, @Name("relationshipTypesAndDirections") String relTypesAndDirs, @Name("maxNodes") long maxNodes) { PathFinder<Path> algo = GraphAlgoFactory.allSimplePaths( new BasicEvaluationContext(tx, db), buildPathExpander(relTypesAndDirs), (int) maxNodes ); Iterable<Path> allPaths = algo.findAllPaths(startNode, endNode); return StreamSupport.stream(allPaths.spliterator(), false) .map(PathResult::new); }  @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 testAllSimplePaths() { db.executeTransactionally(SETUP_MISSING_PROPERTY); testResult(db, "MATCH (from:Loc{name:'A'}), (to:Loc{name:'D'}) " + "CALL apoc.algo.allSimplePaths(from, to, 'ROAD>', 3) yield path " + "RETURN path ORDER BY length(path)", res -> { Path path; path = (Path) res.next().get("path"); assertEquals(1, path.length()); path = (Path) res.next().get("path"); assertEquals(2, path.length()); path = (Path) res.next().get("path"); assertEquals(3, path.length()); assertEquals(false, res.hasNext()); } ); }