I have a directed multigraph. Using the following query, I managed to get the set of nodes that is connected with the node n1_34
MATCH (n1:Node{uuid: "n1_34"}) -[r]- (n2:Node) RETURN n2, r
This yields the nodes n1_1187, n2_2280, n2_1834 and n2_722 and their relationship as seen in the figure.
From here I need to sort the result based on the number their relationships within this subgraph. That means, n1_1187 should be on top with 4 relationships while the others comes after that with 1 relationship.
Thank you, Cobra but this is not what I need. count(r) gives the number of relationship r between n1 (node with uuid "n1_34") and the n2 nodes.
Maybe I am not very clear in the question. Here is the subgraph with n1, n2 and r as the results:
Seeing the figure, you can see why count(r) isn't the one I am looking for and will give the number relationship between n1 and each n2 nodes. Hence, 1 for each n2 nodes.
With the query MATCH (n1:Node{uuid: "n1_34"}) -[r]- (n2:Node) RETURN n2, r , I can get the neighbours. But then somehow I need to traverse each node in context of the subgraph. I dont know how.
I just think I need to traverse the n2 since I need their relationships not the n1's relationship. I once thought this following query will work: MATCH (n1:Node{uuid: "n1_34"}) -- (n2:Node) -[r]- () RETURN n2.uuid AS uuid, count(r) AS n ORDER BY n DESC. But this gives me the number of the relationship of the n2 nodes in an entire graph like this: