cities = [(281, 468), (515, 643), (738, 88), (530, 120), (410, 754) ] import support import random def test_d() : print( "testing d()" ) print() x = cities.copy() a = 2 b = 4 print( "cities:", x ) print( "a:", a ) print( "b:", b ) result = support.d( x, a, b ) if ( result != None ) : result = round( result, 1 ) print() print( "d( cities, a, b ): ", result ) print( "\n--------------------------------------\n" ) def test_swap() : print( "testing swap()" ) print() n = len( cities ) random.seed( 1112 ) tour = list( range( 0, n ) ) random.shuffle( tour ) i1 = 2 i2 = 4 print( "i1:", i1 ) print( "i2:", i2 ) print( "tour before swapping at indices i1 and i2:", tour ) support.swap( tour, i1, i2 ) print( "tour after swapping at indices i1 and i2:", tour ) print( "\n--------------------------------------\n" ) def test_cost() : print( "testing cost()" ) print() tour = [4, 2, 0, 3, 1] print( "cities:", cities ) print( "tour:", tour ) print() x = cities.copy() y = tour.copy() result = support.cost( x, y ) if ( result != None ) : result = round( result, 1 ) print( "cost( cities, tour ): ", result ) if ( __name__ == "__main__" ) : import test_support test_support.test_d() test_support.test_swap() test_support.test_cost()