11package com .bytecodedl .pathfinder ;
22
3- import org .neo4j .graphalgo .GraphAlgoFactory ;
4- import org .neo4j .graphalgo .PathFinder ;
5- import org .neo4j .graphalgo .WeightedPath ;
63import org .neo4j .graphalgo .impl .util .PathImpl ;
74import org .neo4j .graphdb .*;
85import org .neo4j .graphdb .traversal .*;
96import org .neo4j .logging .Log ;
107import org .neo4j .procedure .*;
118
12- import java .nio .DoubleBuffer ;
139import java .util .Collections ;
1410import java .util .List ;
1511import java .util .Optional ;
@@ -31,11 +27,15 @@ public class FindAnyOnePath {
3127
3228 @ Procedure (name = "bytecodedl.findOnePath" , mode = Mode .READ )
3329 @ Description ("find one path from start to end under maxlength, also show first multi dispatch" )
34- public Stream <PathRecord > findOnePath (@ Name ("start" ) Node start , @ Name ("end" ) Node end , @ Name ("maxLength" ) long maxLength , @ Name (" callProperty" ) String callProperty ){
30+ public Stream <PathRecord > findOnePath (@ Name ("start" ) Node start , @ Name ("end" ) Node end , @ Name ("maxLength" ) long maxLength , @ Name (value = "relationshipType" , defaultValue = "Call" ) String relationType , @ Name ( value = " callProperty" , defaultValue = "insn " ) String callProperty ){
3531 final Traverser traverser = tx .traversalDescription ()
3632 .breadthFirst ()
37- .evaluator (Evaluators .toDepth ((int )maxLength ))
38- .expand (PathExpanders .forTypeAndDirection (RelationshipType .withName ("Call" ), Direction .OUTGOING ))
33+ .evaluator (new FindAnyOneEvaluator (end , maxLength ))
34+ .expand (
35+ PathExpanderBuilder .empty ()
36+ .add (RelationshipType .withName (relationType ), Direction .OUTGOING )
37+ // filter non delete relation
38+ .addRelationshipFilter (relationship -> relationship .getProperty ("is_deleted" , "0" ).equals ("0" )).build ())
3939 .uniqueness (Uniqueness .NODE_GLOBAL )
4040 .traverse (start );
4141
@@ -44,9 +44,9 @@ public Stream<PathRecord> findOnePath(@Name("start") Node start, @Name("end") No
4444
4545 @ Procedure (name = "bytecodedl.biFindOnePath" , mode = Mode .READ )
4646 @ Description ("find one path from start to end between minlength and maxlength, also show first multi dispatch" )
47- public Stream <PathRecord > biFindOnePath (@ Name ("start" ) Node start , @ Name ("end" ) Node end , @ Name ("maxLength" ) long maxLength , @ Name (" callProperty" ) String callProperty ){
47+ public Stream <PathRecord > biFindOnePath (@ Name ("start" ) Node start , @ Name ("end" ) Node end , @ Name ("maxLength" ) long maxLength , @ Name (value = "relationshipType" , defaultValue = "Call" ) String relationType , @ Name ( value = " callProperty" , defaultValue = "insn " ) String callProperty ){
4848 TraversalDescription base = tx .traversalDescription ().depthFirst ().uniqueness (Uniqueness .RELATIONSHIP_GLOBAL );
49- PathExpander expander = PathExpanders . forTypeAndDirection ( RelationshipType .withName ("Call" ), Direction .OUTGOING );
49+ PathExpander expander = PathExpanderBuilder . empty (). add ( RelationshipType .withName (relationType ), Direction .OUTGOING ). addRelationshipFilter ( relationship -> relationship . getProperty ( "is_deleted" , "0" ). equals ( "0" )). build ( );
5050 int maxDepth = (int ) maxLength ;
5151
5252 final Traverser traverser = tx .bidirectionalTraversalDescription ()
0 commit comments