Fork me on GitHub
#asami
<
2023-03-10
>
Mattias13:03:11

Is there a concise way of finding nodes with a specific node as grandparent? (parent and/or grandparent works for my specific thing) 🙂

quoll14:03:13

:find ?node
:where [?node :parent ?p][?p :parent *specific*node*]

quoll14:03:59

:find ?node
:where (or (and [?node :parent ?p] [?p :parent *specific*node*]) [?node :parent *specific*node])

quoll14:03:43

The second one is the one where you’re looking for the parent or grandparent

quoll14:03:24

If you want more concise, then I need to finish my SPARQL implementation

quoll14:03:21

Of course, *specific*node* would be set up according to your context. Literal syntax, or a variable bound via :in, etc

Mattias14:03:13

All good, thanks a lot. I was looking at the docs for transitive attributes, and others, and was thinking there was a shortcut for specifying the max path allowed for whatever. 😄

quoll16:03:48

Ah… there is no way to specify the maximum non-looped path, sorry. It wouldn’t be hard to add to the algorithm, but adding to the query syntax is tricky!