Kuhn’s matching algorithm
Kuhn’s algorithm helps as many children as possible get a place in a club they like. Each child lists the clubs they want to join. Each club has one place, and each child can take just one.
Suppose Lena likes chess and art, while Vanya only wants chess. If Lena takes the chess place, Vanya misses out. Move Lena to art and both can join a club they like. On the diagram, children are on the left and clubs on the right. A line shows a club the child wants to join. Drag a vertex across the middle to change sides.
Time is O(L(V + E)), where L is the left side’s size.