Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-13-2020 10:41 PM
So here's my dilemma...
I want to be able to find distinct pairs of node with some value (a: nodeA {number: 1}), that are found in node (b)
by distinct pairs I mean:
1,2
3,4
and not:
1,2
2,1
I'm just looking for the proper syntax so I can implement it in my code.
Solved! Go to Solution.
10-14-2020 04:57 PM
For distinct node pairs, once you have the variables for both nodes, you can use the following to get rid of mirrored results:
...
WITH n1, n2
WHERE id(n1) < id(n2)
...
10-13-2020 11:29 PM
Hello @Shukaku
This is a way of doing this, with APOC you can also sort list of nodes if you need more data from them:
WITH [[1,2], [2,1], [3,4], [4,3], [5,6]] AS list
UNWIND list AS items
WITH apoc.coll.sort(items) AS items_sort, collect(items)[0] AS items_list
RETURN items_list
Regards,
Cobra
10-14-2020 12:23 PM
What if I'm unable to call apoc.coll.sort? is there an alternative to that?
10-14-2020 12:34 PM
To be honest, I'm curious if you find something only in Cypher I had this problem a few days ago and I only found this solution with APOC.
10-14-2020 04:57 PM
For distinct node pairs, once you have the variables for both nodes, you can use the following to get rid of mirrored results:
...
WITH n1, n2
WHERE id(n1) < id(n2)
...
10-14-2020 06:50 PM
Thank you @andrew.bowman and @Cobra!
Andrew's answer is what I was looking for.
All the sessions of the conference are now available online