I am trying to create a query in SPARQL that:
given two or more nodes (selected children) and their parent-child relationship, produces:
least common parent among selected children
shortest paths to least common parent from each child
I am doing this in Neo4j with the following code *(Cypher):
MATCH (children) where children.label IN ["rope", "pope", "dope"]
MATCH (root) where root.label="entity"
WITH * WHERE id(children) < id(root)
MATCH path = allShortestPaths( (children)-[*..100]->(root) )
RETURN path
I know what the "highest common ancestor" is (root) though in this case and are checking paths from found child items to it.
I wonder how one tackles such problems using SPARQL (1.1) and whether it is possible to do these types of queries (and if yes - efficiently).
My example RDF data is WordNet RDF triples and "hypernym" relationship between the nodes.