Single-path function for heavy path based on Klein/Demaine algorithm.

@param it1
@param it2
@param heavyPath
@return distance between subtrees it1 and it2
540499
private double spfH(InfoTree it1, InfoTree it2, int[] heavyPath) {

		int fSize = it1.info[POST2_SIZE][it1.getCurrentNode()];
		int gSize = it2.info[POST2_SIZE][it2.getCurrentNode()];

		int gRevPre = it2.getSize() - 1 - it2.getCurrentNode();
		int gPre = it2.info[POST2_PRE][it2.getCurrentNode()];

		int gTreeSize = it2.getSize();

		int strategy;

		int jOfi;

		// Initialize arrays to their maximal possible size for current pairs of
		// subtrees.
		t = new double[gSize][gSize];
		tCOPY = new double[gSize][gSize];
		s = new double[fSize][gSize];
		q = new double[fSize];

		int vp = -1;
		int nextVp = -1;

		for (int it = heavyPath.length - 1; it >= 0; it--) {
			vp = heavyPath[it];
			strategy = it1.info[POST2_STRATEGY][vp];
			if (strategy != BOTH) {
				if (it1.info[POST2_SIZE][vp] == 1) {
					for (int i = gSize - 1; i >= 0; i--) {
						jOfi = jOfI(it2, i, gSize, gRevPre, gPre, strategy,
								gTreeSize);
						for (int j = jOfi; j >= 0; j--) {
							t[i][j] = (gSize - (i + j)) * costIns;
						}
					}
					previousStrategy = strategy;
				}
				computePeriod(it1, vp, nextVp, it2, strategy);
			} else {
				if (it1.info[POST2_SIZE][vp] == 1) {
					for (int i = gSize - 1; i >= 0; i--) {
						jOfi = jOfI(it2, i, gSize, gRevPre, gPre, LEFT,
								gTreeSize);
						for (int j = jOfi; j >= 0; j--) {
							t[i][j] = (gSize - (i + j)) * costIns;
						}
					}
					previousStrategy = LEFT;
				}
				computePeriod(it1, vp, nextVp, it2, LEFT);
				if (it1.info[POST2_SIZE][vp] == 1) {
					for (int i = gSize - 1; i >= 0; i--) {
						jOfi = jOfI(it2, i, gSize, gRevPre, gPre, RIGHT,
								gTreeSize);
						for (int j = jOfi; j >= 0; j--) {
							t[i][j] = (gSize - (i + j)) * costIns;
						}
					}
					previousStrategy = RIGHT;
				}
				computePeriod(it1, vp, nextVp, it2, RIGHT);
			}
			nextVp = vp;
		}
		return t[0][0];
	}
756415
private static boolean polygonDisjointMultiPath_(Polygon polygon_a,
			MultiPath multipath_b, double tolerance,
			ProgressTracker progress_tracker) {
        Point2D pt_a, pt_b;
        Envelope2D env_a_inf = new Envelope2D(), env_b_inf = new Envelope2D();

        MultiPathImpl multi_path_impl_a = (MultiPathImpl)polygon_a._getImpl();
        MultiPathImpl multi_path_impl_b = (MultiPathImpl)multipath_b._getImpl();

        PairwiseIntersectorImpl intersector = new PairwiseIntersectorImpl(multi_path_impl_a, multi_path_impl_b, tolerance, true);

        if (!intersector.next())
            return true; // no rings intersect

        boolean b_intersects = linearPathIntersectsLinearPath_(polygon_a, multipath_b, tolerance);

        if (b_intersects)
            return false;

        Polygon pa = null;
        Polygon p_polygon_a = polygon_a;

        Polygon pb = null;
        Polygon p_polygon_b = null;

        if (multipath_b.getType().value() == Geometry.GeometryType.Polygon)
            p_polygon_b = (Polygon)multipath_b;

        boolean b_checked_polygon_a_quad_tree = false;
        boolean b_checked_polygon_b_quad_tree = false;

        do
        {
            int path_a = intersector.getRedElement();
            int path_b = intersector.getBlueElement();

            pt_b = multipath_b.getXY(multipath_b.getPathStart(path_b));
            env_a_inf.setCoords(intersector.getRedEnvelope());
            env_a_inf.inflate(tolerance, tolerance);

            if (env_a_inf.contains(pt_b))
            {
                PolygonUtils.PiPResult result = PolygonUtils.isPointInPolygon2D(p_polygon_a, pt_b, 0.0);

                if (result != PolygonUtils.PiPResult.PiPOutside)
                    return false;
            }

            if (multipath_b.getType().value() == Geometry.GeometryType.Polygon)
            {
                pt_a = polygon_a.getXY(polygon_a.getPathStart(path_a));
                env_b_inf.setCoords(intersector.getBlueEnvelope());
                env_b_inf.inflate(tolerance, tolerance);

                if (env_b_inf.contains(pt_a))
                {
                    PolygonUtils.PiPResult result = PolygonUtils.isPointInPolygon2D(p_polygon_b, pt_a, 0.0);

                    if (result != PolygonUtils.PiPResult.PiPOutside)
                        return false;
                }
            }

            if (!b_checked_polygon_a_quad_tree) {
                if (PointInPolygonHelper.quadTreeWillHelp(polygon_a, multipath_b.getPathCount() - 1) && (multi_path_impl_a._getAccelerators() == null || multi_path_impl_a._getAccelerators().getQuadTree() == null)) {
                    pa = new Polygon();
                    polygon_a.copyTo(pa);
                    ((MultiPathImpl) pa._getImpl())._buildQuadTreeAccelerator(Geometry.GeometryAccelerationDegree.enumMedium);
                    p_polygon_a = pa;
                } else {
                    p_polygon_a = polygon_a;
                }

                b_checked_polygon_a_quad_tree = true;
            }

            if (multipath_b.getType().value() == Geometry.GeometryType.Polygon)
            {
                if (!b_checked_polygon_b_quad_tree) {
                    Polygon polygon_b = (Polygon) multipath_b;
                    if (PointInPolygonHelper.quadTreeWillHelp(polygon_b, polygon_a.getPathCount() - 1) && (multi_path_impl_b._getAccelerators() == null || multi_path_impl_b._getAccelerators().getQuadTree() == null)) {
                        pb = new Polygon();
                        polygon_b.copyTo(pb);
                        ((MultiPathImpl) pb._getImpl())._buildQuadTreeAccelerator(Geometry.GeometryAccelerationDegree.enumMedium);
                        p_polygon_b = pb;
                    } else {
                        p_polygon_b = (Polygon) multipath_b;
                    }

                    b_checked_polygon_b_quad_tree = true;
                }
            }

        } while (intersector.next());

        return true;
	}
706426
public static int getDistance (@Nullable final char [] aStr1, @Nullable final char [] aStr2)
  {
    final int nLen1 = aStr1 == null ? 0 : aStr1.length;
    final int nLen2 = aStr2 == null ? 0 : aStr2.length;

    if (nLen1 == 0)
      return nLen2;
    if (nLen2 == 0)
      return nLen1;

    return _getDistance111 (aStr1, nLen1, aStr2, nLen2);
  }
968083
function(node1, node2, previousPathLength) {
    var isEverythingDefined =
      node1 != undefined &&
      node2 != undefined &&
      node1.x != undefined &&
      node1.y != undefined &&
      node2.x != undefined &&
      node2.y != undefined;
    if(!isEverythingDefined) {
      return undefined;
    }

    return (previousPathLength || 0) + Math.sqrt(
      Math.pow((node2.y - node1.y), 2) + Math.pow((node2.x - node1.x), 2)
    );
  }
624779
public static String getCommonPrefixPath(String first, String second) {

        List<String> firstComponents = getPathComponents(first);
        List<String> secondComponents = getPathComponents(second);
        int minSize = Math.min(firstComponents.size(), secondComponents.size());
        StringBuffer resultBuffer = new StringBuffer();
        for (int i = 0; i < minSize; i++) {
            if (firstComponents.get(i).equals(secondComponents.get(i))) {
                resultBuffer.append("/");
                resultBuffer.append(firstComponents.get(i));
            } else {
                break;
            }
        }
        String result = resultBuffer.toString();
        if (result.length() == 0) {
            result = "/";
        }
        return result;
    }
632173
def iter_tree(jottapath, JFS):
    """"""
    filedirlist = JFS.getObject('%s?mode=list' % jottapath)
    log.debug("got tree: %s", filedirlist)
    if not isinstance(filedirlist, JFSFileDirList):
        yield ( '', tuple(), tuple() )
    for path in filedirlist.tree:
        yield path
720991
public double nonNormalizedTreeDist(LblTree t1, LblTree t2) {
		init(t1, t2);
		STR = new int[size1][size2];
		computeOptimalStrategy();
		return computeDistUsingStrArray(it1, it2);
	}
1216178
@SuppressWarnings("unchecked")
	public TreeNode<T> findByPath(T... path) {
		return findByPath(Arrays.asList(path));
	}
63063
public static <X, Y> Iterable<ZipPair<X, Y>> zip(final Iterable<X> iter1,
      final Iterable<Y> iter2) {
    return new ZipIterable<X, Y>(iter1, iter2);
  }
1112107
public static double getDistance(double x1, double y1, double x2, double y2)
    {
        final double x = x2 - x1;
        final double y = y2 - y1;

        return StrictMath.sqrt(x * x + y * y);
    }
1077483
def _path2point(path):
    """"""
    return {_VARS[node.root]: int(node.hi is path[i+1])
            for i, node in enumerate(path[:-1])}
743315
public double distance(Synset synset1, Synset synset2) {
        Preconditions.checkNotNull(synset1);
        Preconditions.checkNotNull(synset2);
        if (synset1.equals(synset2)) {
            return 0d;
        }
        List<Synset> path = shortestPath(synset1, synset2);
        return path.isEmpty() ? Double.POSITIVE_INFINITY : path.size() - 1;
    }
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;
  }
343128
private void linearScan(Relation<? extends O> relation, DBIDIter iter, O obj, double range, ModifiableDoubleDBIDList result) {
    final PrimitiveDistanceFunction<? super O> rawdist = this.rawdist;
    while(iter.valid()) {
      final double distance = rawdist.distance(obj, relation.get(iter));
      if(distance <= range) {
        result.add(distance, iter);
      }
      iter.advance();
    }
  }
1177059
def find_path(start, goal, neighbors_fnct, reversePath=False, heuristic_cost_estimate_fnct=lambda a, b: Infinite, distance_between_fnct=lambda a, b: 1.0, is_goal_reached_fnct=lambda a, b: a == b):
    """"""
    class FindPath(AStar):

        def heuristic_cost_estimate(self, current, goal):
            return heuristic_cost_estimate_fnct(current, goal)

        def distance_between(self, n1, n2):
            return distance_between_fnct(n1, n2)

        def neighbors(self, node):
            return neighbors_fnct(node)

        def is_goal_reached(self, current, goal):
            return is_goal_reached_fnct(current, goal)
    return FindPath().astar(start, goal, reversePath)
1060348
private double distance(Instance inst1, double[] inst2){
        double distance = 0.0;
        for (int i = 0; i < numDims; i++) {
            double d = inst1.value(i) - inst2[i];
            distance += d * d;
        }
        return Math.sqrt(distance);
    }
1015341
public static int distance(String s1, String s2) {
    if (s1.length() == 0)
      return s2.length();
    if (s2.length() == 0)
      return s1.length();

    int s1len = s1.length();
    // we use a flat array for better performance. we address it by
    // s1ix + s1len * s2ix. this modification improves performance
    // by about 30%, which is definitely worth the extra complexity.
    int[] matrix = new int[(s1len + 1) * (s2.length() + 1)];
    for (int col = 0; col <= s2.length(); col++)
      matrix[col * s1len] = col;
    for (int row = 0; row <= s1len; row++)
      matrix[row] = row;

    for (int ix1 = 0; ix1 < s1len; ix1++) {
      char ch1 = s1.charAt(ix1);
      for (int ix2 = 0; ix2 < s2.length(); ix2++) {
        int cost;
        if (ch1 == s2.charAt(ix2))
          cost = 0;
        else
          cost = 1;

        int left = matrix[ix1 + ((ix2 + 1) * s1len)] + 1;
        int above = matrix[ix1 + 1 + (ix2 * s1len)] + 1;
        int aboveleft = matrix[ix1 + (ix2 * s1len)] + cost;
        matrix[ix1 + 1 + ((ix2 + 1) * s1len)] =
          Math.min(left, Math.min(above, aboveleft));
      }
    }

    // for (int ix1 = 0; ix1 <= s1len; ix1++) {
    //   for (int ix2 = 0; ix2 <= s2.length(); ix2++) {
    //     System.out.print(matrix[ix1 + (ix2 * s1len)] + " ");
    //   }
    //   System.out.println();
    // }
    
    return matrix[s1len + (s2.length() * s1len)];
  }