Adds x, y and euclidiant_distance in utils
This commit is contained in:
parent
d25450444a
commit
e6c615ca39
1 changed files with 12 additions and 0 deletions
12
utils.py
12
utils.py
|
|
@ -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 )
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue