# Grouping data based on a specific pattern [closed]

I have a collection of data for a multiplayer game (2000 games, 10 players each). I would like to create clusters from this data, each containing the ids of 3 players that had played against each other. For example, assume player A played against player B, B played against C, and C played against A. I'm trying to figure out a way to detect A,B, and C from the data. I was thinking of using kmeans but this may not work as i do not know the number of clusters. Please help

## closed as unclear what you're asking by Michael Chernick, kjetil b halvorsen, Firebug, Sean Easter, SmallChessApr 11 '17 at 12:28

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• What's the question? – Firebug Apr 9 '17 at 20:25
• How do i create groups/clusters representing 3 players that had all played against each other from the data – user3117253 Apr 9 '17 at 20:33
• The data includes columns for match id, player id, team id, and Boolean for result – user3117253 Apr 9 '17 at 20:34
• There is a lot of confusion in the question but it does not seem to be so unclear as to be unanswerable - even if the answer is not at all to do with clustering - so I don't think the question should be closed as unclear – Silverfish Apr 9 '17 at 23:51
• What are you hoping for if A played against B, A against B, A against C, A against D, B against C, B against D, c against D? Or some variants of that? – mdewey Apr 10 '17 at 10:22

You appear to be looking for 3-Cliques, not for clusters.

Unless you are also looking for larger cliques, you likely won't find an "algorithm" for this, because it is straightforward.

For any node A:
For any neighbors B < C of A:
If A < B and B and C are connected:
report ABC as 3-clique


Clustering algorithms try to solve a different problem, so they won't be useful to you.

• Thank you for your reply. I researched cliques and understood that they are detected from graphs. I can use networkx to solve this in python. I read the documentation on networkx, but have not successfully managed to go about it. Do you know where i can find a good tutorial for solving this? I'm currently stuck in building a graph representation from the dataframe. My data columns are gameId, players ids under each team, and the outcome of the game for each team. – user3117253 Apr 11 '17 at 13:30