title: Graph algorithm for dividing students into two groups
body: <p>I'm struggling to create an efficient algorithm that can determine whether a group of students can be divided into two groups. </p>
  
  <p>Note that there are some provided constraints of the type that for <code>(X,Y)</code> student <code>X</code> must be with student <code>Y</code> and some constraints of the type that for <code>(A,B)</code> student <code>A</code> cannot be with student <code>B</code>. Not every student has a constraint on him, and some students have multiple constraints.</p>
  
  <p>I've considered a graph where each student is a node and then two nodes are connected by an edge if the students could be in the same group (e.g. they either have the constraint that they must be together and/or don't have the constraint that they can't be together). But I'm not sure what algorithm I could apply to solve (or proven, given the set of constraints this is impossible), once I have constructed this graph representation. </p>
  
  <p>Any advice is appreciated? Thank you! </p>