Using @recurse as in <neighbor>: [uid] @reverse .
is nice syntactic sugar (good to remember), but doesnt change the problem. If i run e.g.
{
q(func: type(node)) @recurse
{
name
neighbor
}
}
(Slight modification of your queries above), we get:
{
"data": {
"q": [
{
"name": "node_1",
"neighbor": [
{
"name": "node_2"
}
]
},
{
"name": "node_2"
},
{
"name": "node_3",
"neighbor": [
{
"name": "node_4"
}
]
},
{
"name": "node_4"
},
{
"name": "node_3",
"neighbor": [
{
"name": "node_4"
}
]
},
{
"name": "node_4",
"neighbor": [
{
"name": "node_3"
}
]
},
{
"name": "node_1",
"neighbor": [
{
"name": "node_2"
}
]
},
{
"name": "node_2",
"neighbor": [
{
"name": "node_1"
}
]
},
{
"name": "node_2",
"neighbor": [
{
"name": "node_1"
}
]
},
{
"name": "node_3",
"neighbor": [
{
"name": "node_4"
}
]
},
{
"name": "node_4",
"neighbor": [
{
"name": "node_3"
}
]
},
{
"name": "node_1",
"neighbor": [
{
"name": "node_2"
}
]
}
]
},
"extensions": {
"server_latency": {
"parsing_ns": 10169,
"processing_ns": 5402004,
"encoding_ns": 42478,
"assign_timestamp_ns": 534517
},
"txn": {
"start_ts": 30370384
}
}
}
Note that every connected component appears many times, e.g. for the connected component [node_1,node_2]
:
{
"name": "node_1",
"neighbor": [
{
"name": "node_2"
}
]
}
and
{
"name": "node_2",
"neighbor": [
{
"name": "node_1"
}
]
}
Now imagine a connected component consisting of 100’000 nodes. Returning this component should be no problem, but if we return this component more than 100’000 times, we have a problem. So how can we ensure that each connected component is only listed once in the query result??
Sorry, i am mixing up code
and name
during these queries, just think about it as some label of the nodes.