I want to know how many relationships does a query return when there are two MATCH patterns, and I couldn't figure out how to do it.
MATCH (a)-[r1]->(b), (c)-[r2]->(d) WHERE a.name <> d.name AND b.region = c.region AND a.name <> b.name AND c.name <> d.name (and other conditions...) RETURN DISTINCT a.name AS origin, b.name AS halfway1, c.name AS halfway2, d.name AS destination, count(distinct r1) AS qty1, count(distinct r2) AS qty2 ORDER BY (qty1*qty2) DESC
It returns something like that for me (I'm working with the results on Pandas dataframes):
At first, I was just concatenating the first three columns with the last three and dropping rows with the lowest number when both cities are equal to get the sum of all relationships. For example, there are 12 trips from CITY3 to CITY4 in the first row and 15 trips from CITY3 to CITY4 in the second row. So, I consider 15 trips.
However, I possibly lose some relationships doing it, since some of those discarded 12 trips may not be included in the 15 trips I kept.
I hope I made myself clear after all this prelude. In the end, all I want to know is how to return the count of all relationships that query returns to me (both in