One-to-Many Shortest Path query support in Neo4j

ⅰ亾dé卋堺 提交于 2019-12-12 21:36:34

问题


Does neo4j have support for one-to-many shortest path queries? An example of such query would be: Given a node i, and a list of several other nodes N, compute the shortest paths from i to all the nodes that belong to N.

I am aware of this thread: Neo4j shortest path (BFS) distances query variants, but it is specifically for one-to-all queries. My question is for one-to-many queries.

Thank you.


回答1:


To get All paths from one node to multiple nodes

MATCH p = shortestPath((s:skill)-[r]->(s1:skill))
WHERE id(s) = 123
AND id(s1) IN [1,2,3]

RETURN p

This is the one way to get paths between one-to-many. I hope this is what you need.



来源:https://stackoverflow.com/questions/27377196/one-to-many-shortest-path-query-support-in-neo4j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!