# Matching people into groups based on scores

Hello :)

I’m pretty new to neo4j and I’m not sure of what I’m trying to do is possible.

I’m looking to use neo4j for a Mentoring program I am creating. People will be matched into groups of say 10 people based on various criteria, the criteria and people in a group can change but as an example lets say the ideal group will be made up of 7 Mentees, 2 Mentors and a moderator.

People have given details of their interests & age and I’ve created a Score relationship between each person based on how many interests they have and how close their ages are.

The part I’m struggling on is creating the groups based on these scores. Is there something that I can do in Cypher to take say 700 Mentees, 200 Mentors and 100 Moderators and split them into groups of 10 with the best possible score matches (7 mentees would be the maximum and could be less per group) but trying to match as many people as possible to minimise the manual aspect as much as possible.

I hope that makes sense.

Many thanks for any help!

Matt

I think you might be able to use one of the similarity algorithms (https://neo4j.com/docs/graph-algorithms/current/labs-algorithms/similarity/) from the Graph Algorithms library to do this.

If you share a bit more about the data model/some sample data I can write a sample query showing how to do it.

Cheers, Mark

Hi Mark

Thanks for replying! Sorry I don't think I've explained this correctly, I have already used the Similarity algorithms to create a score relationship between each person...
(:User {name: "Matt"}) - [:Score {value:0.8}] - (:User {name: "Kelly"})
(:User {name: "Barry"}) - [:Score {value:0.71}] - (:User {name: "Judy"})
.... etc etc

Simplifying the problem I want to take a group of say 100 people and group them into groups of 10 based on these scores. Is there some way of doing this through Cypher?
Some people may only score highly against 1 or 2 others so I'd like it to be smart enough to match these people first.

If there isn't some kind of algorithm is there some way to chain queries in cypher so results from the previous match are ignored from the next, so..

Match users into groups score over 0.9 and don't score highly against many people..
Match any other users into groups that score over 0.9..
Match any other users into groups that score over 0.8..
And so on, at the same time limiting groups to 10 people

Thanks!

Matt