Return the Euclidean distance between vectors v of
        two trees. Must have the same leaf set (too lazy to check).
194558
def get_distance(self, other, lbda=0.5, min_overlap=4):
        
        if self.tree ^ other.tree:
            if len(self.tree & other.tree) < min_overlap:
                return 0
                # raise AttributeError('Can\'t calculate tree distances when tree overlap is less than two leaves')
            else:
                t1, t2 = self._equalise_leaf_sets(other, False)
                tmp_self = KendallColijn(t1)
                tmp_other = KendallColijn(t2)

                return np.sqrt(((tmp_self.get_vector(lbda) - tmp_other.get_vector(lbda)) ** 2).sum())
        else:
            return np.sqrt(((self.get_vector(lbda) - other.get_vector(lbda)) ** 2).sum())
332348
def compare_trees(self, parsed_pytree, parsed_doctree):
        
        if parsed_pytree == parsed_doctree:
            return 0

        missing_pys, missing_docs = self.calculate_tree_differences(pytree=parsed_pytree,
                                                                    doctree=parsed_doctree)
        self.pprint_tree_differences(missing_pys=missing_pys, missing_docs=missing_docs)
        return 0 if self.args.no_fail else 1
348217
def symmetric_difference(self, other):
        
        if not isinstance(other, set): other = set(other)
        me = set(self)
        ivs = me.difference(other).union(other.difference(me))
        return IntervalTree(ivs)
1004664
def perimeter(self):
        '''
        
        '''
        return sum([a.distance(b) for a, b in self.pairs()])
1190681
public static double getRobustTreeEditDistance(String dom1, String dom2) {

		LblTree domTree1 = null, domTree2 = null;
		try {
			domTree1 = getDomTree(dom1);
			domTree2 = getDomTree(dom2);
		} catch (IOException e) {
			e.printStackTrace();
		}

		double DD = 0.0;
		RTED_InfoTree_Opt rted;
		double ted;

		rted = new RTED_InfoTree_Opt(1, 1, 1);

		// compute tree edit distance
		rted.init(domTree1, domTree2);

		int maxSize = Math.max(domTree1.getNodeCount(), domTree2.getNodeCount());

		rted.computeOptimalStrategy();
		ted = rted.nonNormalizedTreeDist();
		ted /= (double) maxSize;

		DD = ted;
		return DD;
	}
568897
def vector_distance(v1, v2):
    """"""
    dist = 0
    for dim in v1:
        for x in v1[dim]:
            dd = int(v1[dim][x]) - int(v2[dim][x])
            dist = dist + dd**2
    return dist
736869
public static float distanceSq( float[] a , float[]b ) {
		float ret = 0;
		for( int i = 0; i < a.length; i++ ) {
			float d = a[i] - b[i];
			ret += d*d;
		}
		return ret;
	}
1250698
public int calculateNodePathDistance(String nodePath1, String nodePath2) {
    String[] nodePathFragment1 = nodePath1.split("\\.");
    String[] nodePathFragment2 = nodePath2.split("\\.");

    int overlapBlock = 0;
    while (overlapBlock < nodePathFragment1.length
        && overlapBlock < nodePathFragment2.length
        && nodePathFragment1[overlapBlock].equals(nodePathFragment2[overlapBlock])) {
      overlapBlock++;
    }

    return nodePathFragment1.length + nodePathFragment2.length - overlapBlock * 2;
  }
520439
def euclidean3d(v1, v2):
    """"""
    if not len(v1) == 3 and len(v2) == 3:
        print("Vectors are not in 3D space. Returning None.")
        return None
    return np.sqrt((v1[0] - v2[0]) ** 2 + (v1[1] - v2[1]) ** 2 + (v1[2] - v2[2]) ** 2)
563087
def vector_similarity(self, vector, items):
        """"""
        vector = self.normalize(vector)
        items_vec = np.stack([self.norm_vectors[self.items[x]] for x in items])
        return vector.dot(items_vec.T)
935929
def vector_distance(a, b):
    """"""
    a = np.array(a)
    b = np.array(b)
    return np.linalg.norm(a - b)
202174
function getDistanceVector(position1, position2) {
  if (position1 && position2) {
    var x1 = position1.x,
        y1 = position1.y;
    var x2 = position2.x,
        y2 = position2.y;


    return { x: x2 - x1, y: y2 - y1 };
  } else {
    return { x: 0, y: 0 };
  }
}
724013
def distance(self, other):
        
        return distance((self.separation, self.pa), (other.separation, other.pa))
1289141
def distance(self, other):
        
        from numpy.linalg import norm
        if isinstance(other, one):
            other = other.center
        return norm(self.center - asarray(other), ord=2)
372337
def euclidean(a, b):
    ""
    return np.linalg.norm(np.subtract(a, b))
825417
public static float distance (float x1, float y1, float x2, float y2) {
        return FloatMath.sqrt(distanceSq(x1, y1, x2, y2));
    }
925603
@SuppressWarnings({ "cast", "unchecked" })
  public static <O extends SpatialComparable> RangeQuery<O> getRangeQuery(AbstractRStarTree<?, ?, ?> tree, SpatialDistanceQuery<O> distanceQuery, Object... hints) {
    // Can we support this distance function - spatial distances only!
    SpatialPrimitiveDistanceFunction<? super O> df = distanceQuery.getDistanceFunction();
    if(EuclideanDistanceFunction.STATIC.equals(df)) {
      return (RangeQuery<O>) new EuclideanRStarTreeRangeQuery<>(tree, (Relation<NumberVector>) distanceQuery.getRelation());
    }
    return new RStarTreeRangeQuery<>(tree, distanceQuery.getRelation(), df);
  }