Neo4J: shortest paths with specific relation types sequence constrain
问题 I need to find shortest paths between nodes, but with some restrictions on relations types in good paths. I have two relation types: A & B. Path is considered bad if it has two or more consecutive relation of type B: Good path: ()-A->()-A->()<-A-()-B->()-A->()-B->() Bad path: ()-A->()-A->()<-A-() -B->()<-B- ()-A->() The Cypher query: MATCH path=allShortestPaths( (p:P{idp:123})-[rel:A|B*]-(p2:P{idp:124}) ) WHERE *some-predicate-on-path-or-rel* RETURN path is not a solution because the shortest