How can a set of N players be split into M teams, given certain rules?
Denote each person as a single vertex and connect them by an edge if they are not allowed to be in the same team. If several people have to be on the same team, use a single vertex to represent all of them. Then color the resulting graph by $k$ colors, where $k$ is the number of teams.This problem is the graph coloring problem. To complicate things you may require color certain vertices in the same color. Please follow this for other types of colorings.