What I want to do
The problem I’m working on requires finding connected components in a graph. In our dataset, the components can get very big, so before we reach a size where queries become slow / eat all of our RAM, we’d like to ignore the large components (or at least limit how many total nodes our @recurse
query can return).
Limiting the query by means of specifying depth
or taking the first n
edges in a query don’t solve my problem properly, since there’s no way to practically / meaningfully limit how large the components can be.
What I did
Tried controlling query size by changing the depth
parameter and limiting on edges, but these two don’t meaningfully allow me to stop traversing the graph when I find a connected component that’s too big.
My current query looks something like this:
{
q(func: eq(id, "555")) @recurse(loop: false, depth: 5) {
uid
phone_number
~phone_number (first: 5)
email
~email (first: 5)
}
}
but I’d like to be able to stop the recursion when it hits some limit (e.g. 100 nodes). Maybe something like this (which I understand isn’t currently possible):
{
q(func: eq(id, "555")) @recurse(loop: false, first: 100) {
uid
phone_number
~phone_number
email
~email
}
}