Showing results for 
Search instead for 
Did you mean: 

How is the number of random walks determined in GDS?

Node Clone

I am running the random walk algorithm on my Neo4j graph named 'example', with the minimum allowed walk length (2) and walks per node (1). Namely,

    walkLength: 2,
    walksPerNode: 1,
    randomSeed: 42,
    concurrency: 1
YIELD nodeIds, path
RETURN nodeIds, [node IN nodes(path) | ] AS event_name

And I get 41 walks. How is this number determined? I checked the graph and it contains 161 nodes and 574 edges. Any insights? Thanks.


You can run random walk over your entire graph - which will produce random walks for each node - or using a specified start node.

In your example, you've specified one walk of length two per node - so I suspect your graph projection has a total of 41 nodes that can take a 2 step walk. For nodes where paths of the specified length aren't possible, you won't see a result.

If you want to specify the start node, you can provide that with the sourceNodes parameter.

Nodes 2022
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.