Maximum coverage with hard restrictions
The calculation finds the largest number of learners that can be assigned using the permitted connections and individual mentor capacities. It can move an earlier tentative pairing to free a place for somebody with fewer options. This avoids the avoidable gaps that a simple first-come shuffle can create. If the final result is partial, no additional learner can be included without changing the existing rules or rearranging within the same maximum total. No excluded pair is used as a fallback, and nobody is counted twice.