private double getCost() {
		if (boxOverlap()) {
			return Double.MAX_VALUE;
		}
		double result = 0;
		for (ALink alink : galaxy.getLines().keySet()) {
			final PolylineBreakeable orig = lines.get(alink);
			final PolylineBreakeable p = orig;
			result += getLength(p);
			final Box b1 = boxes.get(alink.getNode1());
			final Box b2 = boxes.get(alink.getNode2());
			result += getCostBoxIntersect(p, b1, b2);

			for (ALink alink2 : galaxy.getLines().keySet()) {
				if (alink == alink2) {
					continue;
				}
				final PolylineBreakeable other = lines.get(alink2);
				if (p.doesTouch(other)) {
					result += getLength(other);
					// return Double.MAX_VALUE;
				}
				// result += p.getDistance(other);
			}
		}

		return result;
	}