Adds x, y and euclidiant_distance in utils

This commit is contained in:
Johann Dreo 2014-04-03 22:16:00 +02:00
commit e6c615ca39

View file

@ -1,5 +1,13 @@
import sys
import math
def x( point ):
return point[0]
def y( point ):
return point[1]
def LOG( *args ):
"""Print something on stderr and flush"""
@ -38,3 +46,7 @@ def tour(lst):
for a,b in zip(lst, lst[1:] + [lst[0]]):
yield (a,b)
def euclidian_distance( ci, cj, graph = None):
return math.sqrt( float(ci[0] - cj[0])**2 + float(ci[1] - cj[1])**2 )