Search in sources :

Example 6 with PathSet

use of com.baidu.hugegraph.traversal.algorithm.HugeTraverser.PathSet in project incubator-hugegraph by apache.

the class PathsRecords method findPath.

@Watched
@Override
public PathSet findPath(Id target, Function<Id, Boolean> filter, boolean all, boolean ring) {
    assert all;
    int targetCode = this.code(target);
    int parentCode = this.current();
    PathSet paths = PathSet.EMPTY;
    // Traverse backtrace is not allowed, stop now
    if (this.parentsContain(targetCode)) {
        return paths;
    }
    // Add to current layer
    this.addPath(targetCode, parentCode);
    // If cross point exists, path found, concat them
    if (this.movingForward() && this.targetContains(targetCode)) {
        paths = this.linkPath(parentCode, targetCode, ring);
    }
    if (!this.movingForward() && this.sourceContains(targetCode)) {
        paths = this.linkPath(targetCode, parentCode, ring);
    }
    return paths;
}
Also used : PathSet(com.baidu.hugegraph.traversal.algorithm.HugeTraverser.PathSet) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Aggregations

PathSet (com.baidu.hugegraph.traversal.algorithm.HugeTraverser.PathSet)6 Record (com.baidu.hugegraph.traversal.algorithm.records.record.Record)3 IntIterator (com.baidu.hugegraph.util.collection.IntIterator)3 Id (com.baidu.hugegraph.backend.id.Id)2 Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)2 Path (com.baidu.hugegraph.traversal.algorithm.HugeTraverser.Path)2 ArrayList (java.util.ArrayList)1