I`m creating web app that joins fellow-travelers. So, Person1 planning his ride from point A to point E through points B, C, D (A->B->C->D->E). This route discribed in graph database neo4j and it has relevant nodes A, B, C, D, E and relations that connects points. Other Person2 planning his ride, and he also would be passing through poinds C and D. So, their routes matches in nodes C and D (they moves in one direction). Existing cypher queries allows to find separate nodes, and nodes connected an equal relations. Are there any algorithms, that allows to find more than two nodes connected in one path?
I`m using cypher-manual on neo4j website, but there is no any methods, that allows to solve my task.
Looks like you need to write your own code. Straighforward:
Loop over every pair of routes
Loop over every pair of nodes in route pair
IF identical nodes
add node to matched route
set flag1 false
set flag2 true
WHILE flag2 is true
set flag2 false
IF subsequent nodes are equal
add node to matched route
set flag1 true
set flag2 true
IF flag1 true
Output matched route