Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-01-2022 12:09 AM
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
10-01-2022 08:34 AM
Does this work? sequential 'unwind' operations product a Cartesian product of the data.
with [1,2] as userIds, [10,11] as locationIds, [100,110] as deviceIds
unwind userIds as userId
unwind locationIds as locationId
unwind deviceIds as deviceId
return userId, locationId, deviceId
All the sessions of the conference are now available online