0
votes

I am not an expert in Cypher but I'm in a project where I have several nodes with the following properties:

['COGAB11', 'COGAB7', 'COGAB30', 'COGAB32', 'COGAB94', 'COGAB70',
'COGAB01', 'COGAB04', 'COGAB91', 'COG1AB77', 'COGAB46', 'COGAB40',
'COGAB31', 'COGAB14']

and between them there are several relationships:

[rel:coexpression|cooccurence|database|experimental|
fusion|neighborhood|score|textmining]

which also have a property like score which is a numerical integer value of 0-1000 and I would like to find the shortest path between all these nodes and get the relationships with a score greater than and equal to 500 between them. Therefore, I would like to return the graph with these relationships and path. However, I have only found a query of the shortest path but between two nodes and not between multiple nodes and multiple relationships. Additionally, I'm not sure if I should use APOC for this.

MATCH (start:Loc{name:'A'}), (end:Loc{name:'F'})
CALL algo.shortestPath.stream(start, end, 'cost')
YIELD nodeId, cost
RETURN algo.asNode(nodeId).name AS name, cost
1

1 Answers

2
votes

If you mean that you want each relationship to have a score >= 500, then this should return the shortest path:

MATCH (start:Loc {name: 'A'}), (end:Loc {name: 'F'}),
  p = SHORTESTPATH((start)-[:coexpression|cooccurence|database|experimental|fusion|neighborhood|score|textmining]-(end))
WHERE ALL(r IN RELATIONSHIPS(p) WHERE r.score >= 500)
RETURN p