Created
May 16, 2014 16:12
-
-
Save qmaruf/c9509dea229de935466e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#create db | |
create(a{n:"a"}),(b{n:"b"}),(c{n:"c"}),(d{n:"d"}),(e{n:"e"}), | |
a-[:parent_of]->b, | |
a-[:parent_of]->c, | |
b-[:parent_of]->d, | |
d-[:parent_of]->e, | |
e-[:parent_of]->c, | |
d-[:parent_of]->c; | |
#do query | |
match path=p<-[:parent_of*]-common_ancestor-[:parent_of*]->h | |
return common_ancestor as most_recent_common_ancestor | |
order by length(path) | |
limit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment