A math department would like to offer seven courses. There are eight professors, each of whom is willing to teach certain courses. Find a maximal matching where professors only teach courses they are interested in teaching.
Build a bipartite graph between professors and courses they are interested in teaching.
Wolfram Language code: g = [image];
The maximum flow from all professors to all courses shows the matching.
Wolfram Language code: flowgraph = EdgeAdd[g, Union[Flatten[EdgeList[g] /. {a_b_ :> {"s"a, b"t"}}]]];Wolfram Language code: VertexDelete[FindMaximumFlow[flowgraph, "s", "t", "FlowGraph"], {"s", "t"}]