(coords)
return matrix
A distance matrix
A distance matrix
A distance matrix
def cartesian_matrix(coords):
    """ A distance matrix """
    matrix={}
    for i,(x1,y1) in enumerate(coords):
        for j,(x2,y2) in enumerate(coords):
            dx, dy = x1-x2, y1-y2
            dist=sqrt(dx*dx + dy*dy)
            matrix[i,j] = dist
    return matrix
def cartesian_matrix ( coords ) : matrix = { } for i , ( x1 , y1 ) in enumerate ( coords ) : for j , ( x2 , y2 ) in enumerate ( coords ) : dx , dy = x1 - x2 , y1 - y2 dist = sqrt ( dx * dx + dy * dy ) matrix [ i , j ] = dist return matrix