Hungarian algorithm for maximum matching