What I'm trying to do is generate all the permutations of a collection of nodes but where each node type only appears once per permutation.
For example if I have a graph of u:User, l:Location, d:Device nodes, lets say 3 nodes of each type.
What I want to be able to generate is a collection that might look something like this
User ID: 1, Location ID: 1, Device ID: 1
User ID: 1, Location ID: 1, Device ID: 2
User ID: 1, Location ID: 1, Device ID: 3
User ID: 1, Location ID: 2, Device ID: 1
User ID: 1, Location ID: 2, Device ID: 2
User ID: 1, Location ID: 2, Device ID: 3
And so on, until I have all combinations.
What I don't want to happen is for a valid combination to include any of the node types more than once, so a combination can only have one user, one location and one device.
At the moment I'm using apoc.coll.combinations, but I don't seem to be able to work out a way to stop it from making the node type distinct.
If I were to run
MATCH (l:Location)--(p:Policy)--(ur:UserRisk)
WITH COLLECT({l:l,ur:ur}) as coll
WITH apoc.coll.combinations(coll,1,size(coll)) as combColl
RETURN combColl
I'd run out of memory because valid combos would be all the locations and all the user risks.
Any help would be massively welcome