Implementation of the Hungarian Algorithm