cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 2: migrate recent content

How is the number of random walks determined in GDS?

kasthuri
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,

CALL gds.beta.randomWalk.stream(
  'example',
  {
    walkLength: 2,
    walksPerNode: 1,
    randomSeed: 42,
    concurrency: 1
  }
)
YIELD nodeIds, path
RETURN nodeIds, [node IN nodes(path) | node.name ] 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.

1 REPLY 1

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.