private double minDist(Freckle[] freckles) {
        double minDistance = 0;
        boolean[] inTree = new boolean[freckles.length];
        double[] minDists = new double[freckles.length];
        for (int i = 0; i < freckles.length; i++) {
            minDists[i] = Double.MAX_VALUE;
        }

        int newNode = 0;

        while (inTree[newNode] == false) {
            inTree[newNode] = true;

            double minDist = Double.MAX_VALUE;
            int nextNode = newNode;
            for (int i = 0; i < freckles.length; i++) {
                if (!inTree[i]) {
                    double dist = getDistance(freckles[i], freckles[newNode]);
                    if (dist < minDists[i]) {
                        minDists[i] = dist;
                    }

                    if (minDists[i] < minDist) {
                        minDist = minDists[i];
                        nextNode = i;
                    }
                }
            }
            
            if (nextNode != newNode) {
                newNode = nextNode;
                minDistance += minDist;
            }
        }

        return minDistance;
    }