-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #2402: See if we can make the aStar algorithm support spatial p…
…oints (#2589) (#2786) Co-authored-by: Giuseppe Villani <[email protected]>
- Loading branch information
1 parent
abdd406
commit dd76283
Showing
7 changed files
with
344 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package apoc.algo; | ||
|
||
import apoc.Extended; | ||
import apoc.result.WeightedPathResult; | ||
import org.neo4j.graphalgo.BasicEvaluationContext; | ||
import org.neo4j.graphalgo.CommonEvaluators; | ||
import org.neo4j.graphalgo.GraphAlgoFactory; | ||
import org.neo4j.graphalgo.PathFinder; | ||
import org.neo4j.graphalgo.WeightedPath; | ||
import org.neo4j.graphdb.GraphDatabaseService; | ||
import org.neo4j.graphdb.Node; | ||
import org.neo4j.graphdb.Transaction; | ||
import org.neo4j.procedure.Context; | ||
import org.neo4j.procedure.Description; | ||
import org.neo4j.procedure.Name; | ||
import org.neo4j.procedure.Procedure; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import static apoc.algo.PathFinding.buildPathExpander; | ||
|
||
@Extended | ||
public class PathFindingFull { | ||
|
||
@Context | ||
public GraphDatabaseService db; | ||
|
||
@Context | ||
public Transaction tx; | ||
|
||
@Procedure | ||
@Description("apoc.algo.aStarWithPoint(startNode, endNode, 'relTypesAndDirs', 'distance','pointProp') - " + | ||
"equivalent to apoc.algo.aStar but accept a Point type as a pointProperty instead of Number types as latitude and longitude properties") | ||
public Stream<WeightedPathResult> aStarWithPoint( | ||
@Name("startNode") Node startNode, | ||
@Name("endNode") Node endNode, | ||
@Name("relationshipTypesAndDirections") String relTypesAndDirs, | ||
@Name("weightPropertyName") String weightPropertyName, | ||
@Name("pointPropertyName") String pointPropertyName) { | ||
|
||
PathFinder<WeightedPath> algo = GraphAlgoFactory.aStar( | ||
new BasicEvaluationContext(tx, db), | ||
buildPathExpander(relTypesAndDirs), | ||
CommonEvaluators.doubleCostEvaluator(weightPropertyName), | ||
new PathFinding.GeoEstimateEvaluatorPointCustom(pointPropertyName)); | ||
return WeightedPathResult.streamWeightedPathResult(startNode, endNode, algo); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
apoc.algo.aStarWithPoint | ||
apoc.bolt.execute | ||
apoc.bolt.load | ||
apoc.bolt.load.fromLocal | ||
|
Oops, something went wrong.