Skip to main content

Posts

Showing posts with the label bipartite graphs

Understanding the Hungarian Matching Algorithm

What Does It Solve? The  Hungarian Matching Algorithm  solves the  assignment problem : “How do we assign n tasks to n agents such that the total cost is minimized (or total profit is maximized)?” Think of it like: Assigning  jobs to workers Matching  predicted boxes to GT boxes Matching  students to schools  optimally Example Problem We have  3 workers  and  3 jobs . Each cell in the cost matrix shows how much it costs to assign a worker to a job. Cost Matrix: Job1 Job2 Job3 Worker1 9 2 7 Worker2 6 4 3 Worker3 5 8 1 We want to assign each worker to  one job  so that the  total cost is minimized . Algorithm Intuition The Hungarian algorithm operates in phases: [1] Subtract Row Minimums → Make sure each row has a zero [2] Subtract Column Minimums → Ensure each column has a zero [3] Star Zeros → Mark independent zeros (no overlap in row/column) [4] Cover Columns...