It’s a variant of the bin packing problem, but the final size of the diagram is dependent on the graph layout algorithm, which makes it harder.