Using Industry as an input I want to find all the paths to Region and Size.
I can do it for 1 relationship, e.g. Industry to Size:
MATCH (i:Industry)
WHERE i.value in ["7379", "73", "Information Technology"]
MATCH (s:Size)
WHERE s.value in ["Large2", "Large"]
MATCH path=allshortestPaths((i)-[*]->(s))
RETURN path
However, when I execute the next query
MATCH (i:Industry)
WHERE i.value in ["7379", "73", "Information Technology"]
MATCH (s:Size)
WHERE s.value in ["Large2", "Large"]
MATCH (r:Region)
WHERE r.value in ["USA", "North America"]
match path=allshortestPaths((r)<-[*]-(i)-[*]->(s))
return path
LIMIT 50
I receive the following error allShortestPaths(...) requires a pattern containing a single relationship
What alternatives do I have? Changing the structure also is an option for me.
I'm not sure about your strategy with shortestPath. You may be getting the answers that you want without the right strategy to do so. In any case, try this query:
MATCH (i:Industry)
WHERE i.value in ["7379", "73", "Information Technology"]
with collect(i) as inter
MATCH (s:Size)
WHERE s.value in ["Large2", "Large"]
with inter, s
MATCH (r:Region)
WHERE r.value in ["USA", "North America"]
with inter, s, r
match path=allshortestPaths((r)-[*]-(s))
with r, s, inter, path, nodes(path) as ns
where any(n in ns WHERE n in inter)
return path
LIMIT 50
allshortestPaths/shortestPath just takes into consideration the number of hops. Was the previous query useful? I'm trying to get more insight on your intentions :)
You'll probably want to look at the Graph Data Science library and its shortest path implementation, that should take into account relationship weights.