1

I have a RDF triple store with more than 30,000 triples in it. I want to know the shortest path between any two triples in the store for all edges (If there exists a path between them).

Calculate length of path between nodes? is something similar to what I am looking for. But the proposed solution works for Trees, mine would be a directed graph with multiple paths and with blank nodes.

Is it possible to find the shortest length of the path between two nodes using SPARQL queries? Performance is not an issue at all for my use case.

Or the use of Dijkstra or BFS algorithm is a better solution?

Thanks for all the help!

Niveditha Karmegam
  • 742
  • 11
  • 28
  • 3
    Short answer: Not possible with a single SPARQL query as the question already pointed out. That's not what SPARQL is made for. You have to use some other graph database in combination with their graph query language like Cypher, Gremlin, GraphQL, etc. or yes, just a simple graph lib like JGraphT if the data fits into memory (30000 triples is small so it works for sure) – UninformedUser Mar 24 '19 at 15:05
  • @AKSW Thanks a lot! This was helpful. – Niveditha Karmegam Mar 24 '19 at 22:40
  • 1
    If you found an appropriate solution for your problem you could eventually post it here as an answer. I can imagine that this question is relevant for others as well, so they might be interested how to workaround the limitations of SPARQL. Cheers – UninformedUser Mar 25 '19 at 06:53

0 Answers0