Reputation: 5787
Here I am using neo4j rest api, in first step I want to collect information like how many relationships are there between two given nodes.
Sample : MATCH (n:Node {id: {parameter1}})-[r:someType]-(m:Node {id: {parameter2}}) RETURN COUNT(r)
Then I would like to collect all the values assigned to the edges so I can calculate further calculations. I need all the different types of relationships and their properties between two given nodes.
If it is possible I would like to do it in single cypher.
Upvotes: 5
Views: 6506
Reputation: 32680
Then I would like to collect all the values assigned to the edges
MATCH (n:Node {id: {parameter1}})-[r:someType]-(m:Node {id: {parameter2}})
RETURN COUNT(r) AS count, COLLECT(r) AS rels
Note that the only thing I changed was adding collect(r) AS rels
to the return, which gives you a collection of Relationship
objects representing all edges with label someType
between these nodes.
To get all edges of any type:
MATCH (n:Node {id: {parameter1}})-[r]-(m:Node {id: {parameter2}})
RETURN COUNT(r) AS count, collect(r) AS rels ORDER BY labels(r)
Remove the label requirement from the MATCH
to return a collection of all relationships of any type. Order that collection by label, so that the list of relationships returned is sorted by type, making it easy for you to distinguish between them as needed for the purposes of your "further calculations"
This code is untested, and I'm not 100% sure you can call labels on a collection. If not, let me know and I'll provide an alternate solution.
Upvotes: 6