I have a game where players enter a queue/lobby and wait to be matched into a game. Each game must have 6 players in total, the gender balance has to be even, 3 males, 3 females.
I have a graph of nodes of type "Player" where the nodes are players and each player has a relationship to other nodes who fit their interests.
The relationship between Player nodes is called "IsCompatibleWith". This relationship only exists if player's preferred genders are mutual, i.e. if a male player prefers males, and there's another male player who prefers males, their two nodes would have the relationship.
Each Player node has a property "Gender" and "PreferredGender" which denotes each players own gender and the gender they want to play with.
I am trying to figure out a cypher that will return all possible combinations of 3 males and 3 females where their preferred genders match (i.e. 3 males seeking 3 females and vice-versa). The output values of each combination can be the Player IDs of each player, e.g. [[1,2,3, 4, 5, 6], [1, 2, 3, 8, 9, 10]], etc.
e.g. return all combinations of 3 males and 3 females where the males' preferredGender is female and the females' preferred gender is male.
There can be upwards of hundreds of players waiting to be matched into a game, so the more performant the better, although i do suspect calculating all possible combinations of potentially hundreds of entities can be very slow.
Any help is appreciated here. Let me know if this is feasible with Cypher or if a graph is even the best data structure/solution for this kind of application/problem.