Class BFS


  • public final class BFS
    extends org.neo4j.gds.Algorithm<org.neo4j.gds.core.utils.paged.HugeLongArray>
    Parallel implementation of the BFS algorithm. It uses the concept of bucketing/chunking to keep track of the ordering of the visited nodes. Conceptually, a bucket keeps all nodes at a fixed distance from the starting node. The nodes within each bucket are kept in a list ordered by their final position in the output BFS ordering. To implement parallelism, the nodes within a bucket are processed concurrently. For this, the nodes of the bucket are partitioned into chunks, where each chunk contains a continuous segment from the list of nodes. Threads are then assigned chunks in parallel and process (relax) each node within the assigned chunk. To maintain a correct ordering, once the parallel processing phase has concluded, we perform a sequential step, where we examine the chunks from earliest to latest to create the next bucket, such that a correct BFS ordering is returned where all descendants from the nodes of a chunk, appear together before those from a later chunk.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ALL_DEPTHS_ALLOWED  
      • Fields inherited from class org.neo4j.gds.Algorithm

        progressTracker, terminationFlag
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.neo4j.gds.core.utils.paged.HugeLongArray compute()  
      static BFS create​(org.neo4j.gds.api.Graph graph, long startNodeId, ExitPredicate exitPredicate, Aggregator aggregatorFunction, int concurrency, org.neo4j.gds.core.utils.progress.tasks.ProgressTracker progressTracker, long maximumDepth)  
      void release()  
      • Methods inherited from class org.neo4j.gds.Algorithm

        getProgressTracker, getTerminationFlag, setTerminationFlag
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • create

        public static BFS create​(org.neo4j.gds.api.Graph graph,
                                 long startNodeId,
                                 ExitPredicate exitPredicate,
                                 Aggregator aggregatorFunction,
                                 int concurrency,
                                 org.neo4j.gds.core.utils.progress.tasks.ProgressTracker progressTracker,
                                 long maximumDepth)
      • compute

        public org.neo4j.gds.core.utils.paged.HugeLongArray compute()
        Specified by:
        compute in class org.neo4j.gds.Algorithm<org.neo4j.gds.core.utils.paged.HugeLongArray>
      • release

        public void release()
        Specified by:
        release in class org.neo4j.gds.Algorithm<org.neo4j.gds.core.utils.paged.HugeLongArray>