问题
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