0

In KG we have sample Rdf triples be like. input1 <---- f(x) -----> ouput1 <----- f(x) -----> output2 <----- f(x) -----> output3

My goal is to find all posibble paths from Input1 - output3. we start from (Input1) and everytime we will try to find f(x) and ouput with given input. SPARQL - ?function has_input input.?function has_output ?output. when we got some (ouput)s, they become input for the next query and so on until we found goal output(output3).

As I am finding all posible paths so I just implemented a backtracking algorithm to consider all nodes and find all path combinations.

Problem: It takes too long time to finding all possible paths in worst case scenerio. Is there any solution that is related to semantic web? or any optimization technique for this scenerio to reduce time of backtrack?

  • 2
    the solution is to use an appropriate query language. SPARQL isn't meant to gather paths in a graph, there are plenty better suited languages like Cypher, Gremlin, etc. - that said, the closest you can get via a single SPARQL query was provided here: https://stackoverflow.com/questions/18024413/finding-all-steps-in-property-path – UninformedUser Feb 14 '23 at 19:23

0 Answers0