Class MultiSourceBFSRunnable
- java.lang.Object
-
- org.neo4j.gds.msbfs.MultiSourceBFSRunnable
-
- All Implemented Interfaces:
java.lang.Runnable
public final class MultiSourceBFSRunnable extends java.lang.Object implements java.lang.RunnableMulti Source Breadth First Search implemented as described in [1].The benefit of running this MS-BFS instead of multiple execution of a regular BFS for every source is that the MS-BFS algorithm can collapse traversals that are the same for multiple nodes. If any two or more given BFSs would traverse the same nodes at the same iteration depth, the MS-BFS will traverse only once and group all sources for this traversal.
The consumer of this algorithm provides a callback function, the gets called with:
- the node id where the BFS traversal is at
- the depth or BFS iteration at which this node is traversed
- a lazily evaluated list of all source nodes that have arrived at this node at the same depth/iteration
We use a fixed
ω(OMEGA) of 64, which allows us to implement the seen/visitNext bit sets as a packed long which improves memory locality as suggested in 4.1. of the paper. If the number of sources exceed 64, multiple instances of MS-BFS are run in parallel.If the MS-BFS runs in parallel, the callback may be executed from multiple threads at the same time. The implementation should therefore be thread-safe.
[1]: The More the Merrier: Efficient Multi-Source Graph Traversal
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MultiSourceBFSRunnablecreateWithoutSeensNext(long nodeCount, org.neo4j.gds.api.RelationshipIterator relationships, ExecutionStrategy strategy, boolean allowStartNodeTraversal, long[] sourceNodes)voidrun()Runs MS-BFS, always single-threaded.java.lang.StringtoString()
-
-
-
Method Detail
-
createWithoutSeensNext
public static MultiSourceBFSRunnable createWithoutSeensNext(long nodeCount, org.neo4j.gds.api.RelationshipIterator relationships, ExecutionStrategy strategy, boolean allowStartNodeTraversal, long[] sourceNodes)
-
run
public void run()
Runs MS-BFS, always single-threaded. Requires that there are at most 64 source nodes.- Specified by:
runin interfacejava.lang.Runnable
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-