public static <V, E> Rectangle getBoundsForVerticesInLayoutSpace(Collection<V> vertices,
			Function<V, Rectangle> vertexToBounds) {

		if (vertices.isEmpty()) {
			throw new IllegalStateException("No vertices for which to find bounds!");
		}

		double largestX = 0;
		double largestY = 0;

		double smallestX = Integer.MAX_VALUE;
		double smallestY = Integer.MAX_VALUE;

		for (V v : vertices) {

			Rectangle bounds = vertexToBounds.apply(v);

			int halfWidth = bounds.width >> 1;
			int halfHeight = bounds.height >> 1;
			double vertexX = bounds.getX();
			double vertexY = bounds.getY();

			double componentMinX = vertexX - halfWidth;
			double componentMinY = vertexY - halfHeight;
			double componentMaxX = vertexX + halfWidth;
			double componentMaxY = vertexY + halfHeight;

			smallestX = Math.min(componentMinX, smallestX);
			smallestY = Math.min(componentMinY, smallestY);
			largestX = Math.max(componentMaxX, largestX);
			largestY = Math.max(componentMaxY, largestY);
		}

		int width = (int) (largestX - smallestX);
		int height = (int) (largestY - smallestY);
		return new Rectangle((int) smallestX, (int) smallestY, width, height);
	}
Returns a rectangle that contains all vertices, in the layout space

@param vertices the vertices for which to calculate the bounds

@param vertexToBounds a function that can turn a single vertex into a rectangle
@return the bounds
Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/GraphViewerUtils.java