Reputation: 795
I'm trying to build a large-ish social network graph with ArangoDB. I've got the data in there - about 35k vertices with about 150k edges.
I realize that's an awful lot of data, so I was hoping to draw only a subset at a time - maybe 2 or 3 degrees of separation from the starting point.
But I get a 1909: too many iterations
error if maxDepth is greater than 1, even if I set maxIterations very low (say, 1)
For instance, this query gives me a too many iterations error
GRAPH_TRAVERSAL('Friends', 'people/1342', 'outbound', {maxDepth: 2, maxIterations: 10})
If I omit maxIterations I get the same error.
The graph draws successfully in the web interface, so I don't think the problem is with my data per se. Do I just have more data in my graph than ArangoDB can handle? Or am I doing something wrong?
Upvotes: 2
Views: 155
Reputation: 9097
The maxIterations
parameter controls after how many iteration a traversal automatically aborts. This automatic abortion is there to protect you from traversing endlessly when running a traversal on a cyclic graph.
The maxIterations
does not control the traversal depth, but after how many vertices the traversal will stop and throw an error.
Here is an example how to figure out a maximum value:
The traversal will start at the specified start vertex. This is the first iteration. For the start vertex, all outgoing (or ingoing) connections will be determined. Let's say there are five connections to follow from the start vertex, so the next round of the traversal will consider them. So will need at least a value of 6 for maxIterations
(1 for start vertex plus 5 for next round). If now every of the 5 vertices also has 5 connections each, you need at least 25 iterations more, so you'll need a maxIterations
value of 31. For the next level, with 5 connections each, you will need 125 more etc.
So for each level you cannot simply add a constant value for maxIterations
. The series we have seen (1, 6, 31, 156) is clearly non-linear. How many iterations you will need clearly depends on the underlying data and how connected the vertices are.
If all you want to achieve is to limit the traversal depth to a certain level, you can use the minDepth
or maxDepth
parameters, and set maxIterations
to a very high value (that likely will never be reached because the traversal is bounded by maxDepth
). Further options to control the amount of data coming out of a traversal are direction
(any
will produce most result and can more easily lead to cycles, use inbound
or outbound
whenever possible) and uniqueness
(to control how often a given vertex or connecting edge will be visited).
Upvotes: 3
Reputation: 683
maxIterations is a threshold which shall control too many calculation cycles. So, the larger the graph and the more edges/nodes are in the game, the MORE calculation cycles you need (and the higher the maxIterations parameter should be).
So, try to smoothly increase maxIterations for maxDeth == 2 and so on. But not too smoothly, e.g. try+1 := try*10 :-)
Upvotes: 2