Getting all vertices emerging from one node in DAG (infinite steps)

Given DAG (Directed Acyclic Graph) stored in Nebula-graph, I need to get all the decedents of a node using one query executed on the server side. In ‘Go n steps from’ we need to specify the number of steps of depth. How can I do something like bring all the nodes without giving specific step count.
Is there a play around for that? any ideas to do it in programming ( I am using JAVA API client)?
My main goal to reduce the network overhead of the operation by having the server do it on its side.

“get all the decedent of a node” there are two directions from there:

  1. Get all related nodes of a known node v1,such as v1->v2; v1->v3; v1->v4 … , expected (v2, v3, v4,…)
  2. traverse the graph from a known node v1, shch as v1->v2->v3->v4 …, expected (v2, v3, v4,…)

I need to get all the nodes reachable from v1 for infinite number of hops . As per the previous example that mean 1+2.
Any ideas?
Thank you in advance


There will be a subgraph algorithm to be supported in next nebula version, which can solve your problem. And now you can use client api to do that, for example:

  1. use client api to fetch all neighbors of above node v1 by GO 1 STEPS FROM v1 OVER *
  2. execute a loop on above result set, and continue to fetch their neighbors recursively
  3. collect each step results

Pseudo code:

expectedSet = []
vertices = [v1]
while (!vertices.empty()) {
  tmpSet = []
  for v in vertices {
    resultSet = client.execute(sprintf(`GO 1 STEPS FROM %d OVER *`, v))
    expectedSet = append(expectedSet, resultSet)
    tmpSet = append(tmpSet, resultSet)
  vertices = tmpSet

I would prefer not to use the recursive solution which involves network overhead that contradict my goal to have it done only by the server. The client should receive the whole result once!

Agree with you. But, currently, there isn’t a better solution for you since GO n STEPS statement only returns n-th step results. In nebula 2.0, we will support the algorithm to get all nodes inside n steps. This is woking in progress.

1 Like