def test_findLowestEdgeCost (self): supplyLabels = [ 10,-1,10 ] demandLabels = [ -1,10,10 ] costMatrix = numpy.arange ( 9 ).reshape ( 3,3) lowestCost = HungarianAssignment._findLowestEdgeCost (supplyLabels, demandLabels, costMatrix) self.failUnless ( lowestCost == 6)
def test_reviseCostMatrix (self): costMatrix =self.costMatrix a, b, costMatrix2, partialGraphMatrix = HungarianAssignment.HA_Step1_ConstructInitialPartialGraph ( costMatrix ) supplyLabels = [0,'*',-1,-1] demandLabels = [1,-1,-1,-1] delta = HungarianAssignment._findLowestEdgeCost (supplyLabels, demandLabels, costMatrix2) self.failUnless ( delta == 4) # see page 320 of 'Networks and Algorithms' revCostMatrix = HungarianAssignment._reviseCostMatrix (delta, costMatrix2, supplyLabels, demandLabels ) self.failUnless ( revCostMatrix.sum () == 35)