2

I have a couple of questions regarding the capabilities of Dgraph regarding graph traversal.

Let's say we have a dataset that consists of nodes of the type post. Each post can have n posts that are replies to this post. The depth of this tree is not limited.

Is it possible with Dgraph to search trough all leaf nodes starting from one starting node and return all leafs that fulfill a certain condition?

Is it possible to set a depth limit to not end up with a gigantic dataset?

Is it also possible to find the children of all parent nodes that fulfill a certain condition?

And finally: Are edges in Dgraph directed? And can I include that in the query?

Ole Spaarmann
  • 15,845
  • 27
  • 98
  • 160

1 Answers1

7

Author of Dgraph here.

Is it possible with Dgraph to search trough all leaf nodes starting from one starting node and return all leafs that fulfill a certain condition?

Yes. You could use the recurse directive (https://docs.dgraph.io/query-language/#recurse-query).

Is it possible to set a depth limit to not end up with a gigantic dataset?

Yes. Recursion supports a maximum depth.

Is it also possible to find the children of all parent nodes that fulfill a certain condition?

Yes. You can traverse an edge, and put a filter on it. https://docs.dgraph.io/query-language/#applying-filters

And finally: Are edges in Dgraph directed? And can I include that in the query?

Edges in dgraph are directed. But, Dgraph also supports a "reverse" index, which can be used to automatically generate the edges in the reverse direction. You can then traverse these reverse edges, by adding a tilde (~) in front of the predicate name.

https://docs.dgraph.io/query-language/#reverse-edges

Manish Jain
  • 241
  • 1
  • 2
  • 1
    Thank you for your thorough answer. I really start to like Dgraph, was using Neo4j before. I like the fact that it is easily distributed and scalable, that it is close to GraphQL, that it seems to be very fast, that it is written in Go, the license and the development speed of your team. Thank you for creating it! There is no client in Elixir though, only a Http wrapper library. That is sad, because Elixir is a fantastic language. But that led to me learning gRPC (well, the basics) and now trying to figure out how much work it is to write a simple gRPC client in Elixir myself. – Ole Spaarmann Feb 22 '18 at 19:58