I'm using neo4j with wordnet to be able to calculate the similarity between words. However I'm not too good with cypher yet.
What I want is to be able to get the path between two nodes in a hierarchal pattern, but I need to know the ancestor in the middle of them. So if you consider this graph and assume each block is a word and we have the c node and b node already and want to get the path and for it to be able to return the ancestor node, a.
The query i was trying with was
MATCH
(synset:wdo#Synset
{id:"wn/100015568-n"}),
(synset1:wdo#Synset
{id:"wn/113957498-n"}),
path = shortestPath((synset)-[:wdo#hyponym
|wdo#hypernym
*]-(synset1))
return path
which got me the path but I can't get the shared ancestor from it. Any help would be appreciated thank you.
hyponym
andhypernym
relationships are opposites of each other. Is that correct? If the data is modelled with a mix of these edges, that will make finding the common root of the tree more difficult. - Gabor Szarnyaswdo#Synset
{id:"wn/100015568-n"})-[:wdo#hyponym
|wdo#hypernym
]->(middle:wdo#Synset
)<-[:wdo#hyponym
|wdo#hypernym
]-(synset1:wdo#Synset
{id:"wn/113957498-n"}) return synset But it seemed like it wasn't even going to ever finish the query. The shortestPath was almost instant. - Ryan Kauk