-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add end node filter and relationship filter
- Loading branch information
Showing
4 changed files
with
64 additions
and
20 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
36 changes: 36 additions & 0 deletions
36
src/main/java/com/bytecodedl/pathfinder/FindAnyOneEvaluator.java
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,36 @@ | ||
package com.bytecodedl.pathfinder; | ||
|
||
import org.neo4j.graphdb.Node; | ||
import org.neo4j.graphdb.Path; | ||
import org.neo4j.graphdb.traversal.Evaluation; | ||
import org.neo4j.graphdb.traversal.Evaluator; | ||
|
||
|
||
/** | ||
* @author [email protected] | ||
* @date 2023/12/16 16:40 | ||
*/ | ||
public class FindAnyOneEvaluator implements Evaluator { | ||
private Node endNode; | ||
private long maxLength; | ||
|
||
public FindAnyOneEvaluator(Node endNode, long maxLength){ | ||
this.endNode = endNode; | ||
this.maxLength = maxLength; | ||
} | ||
|
||
@Override | ||
public Evaluation evaluate(Path path) { | ||
if (path.length() > this.maxLength){ | ||
return Evaluation.EXCLUDE_AND_PRUNE; | ||
} | ||
|
||
Node pathEndNode = path.endNode(); | ||
if (pathEndNode.equals(endNode)){ | ||
return Evaluation.INCLUDE_AND_PRUNE; | ||
} | ||
|
||
return Evaluation.EXCLUDE_AND_CONTINUE; | ||
} | ||
} | ||
|
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