0

Let's say I have a graph like this:

:a :isConnectedTo :b
:b :isConnectedTo :c
:c :isConnectedTo :d

If I run the following query in my Stardog v4.1.3, it returns true

ask {:a :isConnectedTo* :d}

This is great but I would like to know the path between those two resources. Please notice that in my real case, there is potentially multiple paths but I just need one of them, not necessarily the shortest one.

Is there a way to achieve this with sparql ?

Bob Dudan
  • 97
  • 3
  • 9
  • 1
    This has been [answered](http://stackoverflow.com/questions/26698675/sparql-property-path-queries-with-arbitrary-properties/26707541#26707541) already. – Ivo Velitchkov Mar 21 '17 at 10:43
  • Possible duplicate of [SPARQL property path queries with arbitrary properties](http://stackoverflow.com/questions/26698675/sparql-property-path-queries-with-arbitrary-properties) – UninformedUser Mar 21 '17 at 12:14
  • fwiw, we're extending SPARQL for supporting paths (https://blog.stardog.com/a-path-of-our-own/) – Michael Mar 22 '17 at 19:14

1 Answers1

1

I think this could work specifically for your case. Let me know if you succeed.

SELECT ?x ?y ?z WHERE {
    :a :isConnectedTo* ?x .
    ?x ?y ?z .
    FILTER(?y = :isConnectedTo)
    ?z :isConnectedTo* :d .
}