Graph Theory37 sections · 1633 units
Open in Course

School Dance - Graph Construction

(Source and sink setup)

Create nodes: source ss, nn boys, mm girls, sink tt. Edges:

1.1. (s,boyi)(s, \text{boy}_i) with capacity 11 for each boy.

2.2. (boyi,girlj)(\text{boy}_i, \text{girl}_j) with capacity 11 if boy ii likes girl jj.

3.3. (girlj,t)(\text{girl}_j, t) with capacity 11 for each girl.

Max flow through this network equals the maximum number of pairs. Each unit of flow represents one pair dancing together. The capacity 11 ensures each person dances at most once.