Search in sources :

Example 1 with PathImpl

use of org.neo4j.graphalgo.impl.util.PathImpl in project neo4j by neo4j.

the class ShortestPath method hitsToPaths.

private static Collection<Path> hitsToPaths(EvaluationContext context, Collection<Hit> depthHits, Node start, Node end, boolean stopAsap, int maxResultCount, MemoryTracker memoryTracker) {
    Set<Path> paths = HeapTrackingCollections.newSet(memoryTracker);
    for (Hit hit : depthHits) {
        for (PathImpl path : hitToPaths(context, hit, start, end, stopAsap)) {
            memoryTracker.allocateHeap(path.estimatedHeapUsage());
            paths.add(path);
            if (paths.size() >= maxResultCount) {
                break;
            }
        }
    }
    return paths;
}
Also used : Path(org.neo4j.graphdb.Path) PathImpl(org.neo4j.graphalgo.impl.util.PathImpl)

Example 2 with PathImpl

use of org.neo4j.graphalgo.impl.util.PathImpl in project neo4j by neo4j.

the class ShortestPath method hitToPaths.

private static Collection<PathImpl> hitToPaths(EvaluationContext context, Hit hit, Node start, Node end, boolean stopAsap) {
    Collection<PathImpl> paths = new ArrayList<>();
    Iterable<List<Relationship>> startPaths = getPaths(context, hit.connectingNode, hit.start, stopAsap);
    Iterable<List<Relationship>> endPaths = getPaths(context, hit.connectingNode, hit.end, stopAsap);
    for (List<Relationship> startPath : startPaths) {
        PathImpl.Builder startBuilder = toBuilder(start, startPath);
        for (List<Relationship> endPath : endPaths) {
            PathImpl.Builder endBuilder = toBuilder(end, endPath);
            PathImpl path = startBuilder.build(endBuilder);
            paths.add(path);
        }
    }
    return paths;
}
Also used : Relationship(org.neo4j.graphdb.Relationship) HeapTrackingArrayList(org.neo4j.collection.trackable.HeapTrackingArrayList) ArrayList(java.util.ArrayList) HeapTrackingArrayList(org.neo4j.collection.trackable.HeapTrackingArrayList) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) PathImpl(org.neo4j.graphalgo.impl.util.PathImpl) Builder(org.neo4j.graphalgo.impl.util.PathImpl.Builder)

Aggregations

PathImpl (org.neo4j.graphalgo.impl.util.PathImpl)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 HeapTrackingArrayList (org.neo4j.collection.trackable.HeapTrackingArrayList)1 Builder (org.neo4j.graphalgo.impl.util.PathImpl.Builder)1 Path (org.neo4j.graphdb.Path)1 Relationship (org.neo4j.graphdb.Relationship)1