66import org .neo4j .graphalgo .impl .util .PathImpl ;
77import org .neo4j .graphdb .*;
88import org .neo4j .graphdb .traversal .Evaluators ;
9+ import org .neo4j .graphdb .traversal .InitialBranchState ;
910import org .neo4j .graphdb .traversal .Traverser ;
1011import org .neo4j .graphdb .traversal .Uniqueness ;
1112import org .neo4j .logging .Log ;
@@ -37,10 +38,10 @@ public Stream<PathRecord> findOnePath(@Name("start") Node start, @Name("end") No
3738 final Traverser traverse = tx .traversalDescription ()
3839 //.depthFirst()
3940 .breadthFirst ()
40- .evaluator (new FindAnyOneEvaluator (end , maxLength , minLength ))
41- // .expand(new FindAnyOneExpander())
42- .expand (PathExpanders .forTypeAndDirection ( RelationshipType .withName ("Call" ), Direction .OUTGOING ))
43- .uniqueness (Uniqueness .NODE_PATH )
41+ .evaluator (new FindAnyOneEvaluator (end , maxLength , minLength , log ))
42+ .expand (new FindAnyOneExpander (PathExpanders . forTypeAndDirection ( RelationshipType . withName ( "Call" ), Direction . OUTGOING ), log ), new InitialBranchState . State < Boolean >( false , false ))
43+ // .expand(PathExpanders.forTypeAndDirection( RelationshipType.withName("Call"), Direction.OUTGOING ))
44+ .uniqueness (Uniqueness .NODE_GLOBAL )
4445 .traverse (start );
4546
4647 Optional <Path > optionalPath = StreamSupport
@@ -58,36 +59,36 @@ public Stream<PathRecord> findOnePath(@Name("start") Node start, @Name("end") No
5859 }
5960 }
6061
61- @ Procedure (name = "bytecodedl.dijkstra" , mode = Mode .READ )
62- @ Description ("find one path from start to end between minlength and maxlength, also show first multi dispatch" )
63- public Stream <PathRecord > dijkstra (
64- @ Name ("startNode" ) Node startNode ,
65- @ Name ("endNode" ) Node endNode ,
66- @ Name ("weightPropertyName" ) String weightPropertyName ,
67- @ Name (value = "defaultWeight" , defaultValue = "NaN" ) double defaultWeight ,
68- @ Name (value = "numberOfWantedPaths" , defaultValue = "1" ) long numberOfWantedPaths
69- ){
70- PathFinder <WeightedPath > algo = GraphAlgoFactory .dijkstra (
71- buildPathExpander (),
72- (relationship , direction ) -> Util .toDouble (relationship .getProperty (weightPropertyName , defaultWeight )),
73- (int )numberOfWantedPaths
74- );
75- Iterable <WeightedPath > paths = algo .findAllPaths (startNode , endNode );
76-
77- Optional <WeightedPath > optionalPath = StreamSupport
78- .stream (paths .spliterator (), false ).findFirst ();
79-
80- if (optionalPath .isPresent ()){
81- Path path = optionalPath .get ();
82- List <Relationship > multiDispatchRelationship = getFirstMultiDispatch (path , "insn" );
83- List <Path > pathList = multiDispatchRelationship .stream ().map (this ::relationShipToPath ).collect (Collectors .toList ());
84- pathList .add (path );
85- return pathList .stream ().map (PathRecord ::new );
86- }else {
87- return StreamSupport
88- .stream (paths .spliterator (), false ).map (PathRecord ::new );
89- }
90- }
62+ // @Procedure(name = "bytecodedl.dijkstra", mode = Mode.READ)
63+ // @Description("find one path from start to end between minlength and maxlength, also show first multi dispatch")
64+ // public Stream<PathRecord> dijkstra(
65+ // @Name("startNode") Node startNode,
66+ // @Name("endNode") Node endNode,
67+ // @Name("weightPropertyName") String weightPropertyName,
68+ // @Name(value = "defaultWeight", defaultValue = "NaN") double defaultWeight,
69+ // @Name(value = "numberOfWantedPaths", defaultValue = "1") long numberOfWantedPaths
70+ // ){
71+ // PathFinder<WeightedPath> algo = GraphAlgoFactory.dijkstra(
72+ // buildPathExpander(),
73+ // (relationship, direction) -> Util.toDouble(relationship.getProperty(weightPropertyName, defaultWeight)),
74+ // (int)numberOfWantedPaths
75+ // );
76+ // Iterable<WeightedPath> paths = algo.findAllPaths(startNode, endNode);
77+ //
78+ // Optional<WeightedPath> optionalPath = StreamSupport
79+ // .stream(paths.spliterator(), false).findFirst();
80+ //
81+ // if (optionalPath.isPresent()){
82+ // Path path = optionalPath.get();
83+ // List<Relationship> multiDispatchRelationship = getFirstMultiDispatch(path, "insn");
84+ // List<Path> pathList = multiDispatchRelationship.stream().map(this::relationShipToPath).collect(Collectors.toList());
85+ // pathList.add(path);
86+ // return pathList.stream().map(PathRecord::new);
87+ // }else {
88+ // return StreamSupport
89+ // .stream(paths.spliterator(), false).map(PathRecord::new);
90+ // }
91+ // }
9192
9293 public PathExpander <Double > buildPathExpander () {
9394 // PathExpanderBuilder builder = PathExpanderBuilder.allTypesAndDirections();
0 commit comments