I am working on a graph database on ArangoDB and I'm trying to have paths through a random walk. My purpose is from a start vertex V, I get for instance 4 random paths with a specified depth.
As far as from now, I've found the following code that works :
FOR vertex, edge, path IN 4..4 ANY 'Vertex/417438' edge_collection OPTIONS {bfs: TRUE, uniqueVertices : True, uniqueEdges : True}
SORT RAND()
LIMIT 3
FILTER IS_SAME_COLLECTION('Vertex', vertex)
RETURN path
This indeed gives me 3 paths with a depth of 4, but it takes quite a long time because of the SORT RAND() at the beginning. I guess it first sorts randomly all the possible solution and then returns the solution.
Do you think, there's a way to have random solutions that costs less time?
Thanks for your time and for your futures answers