要找到一种有效的算法,用于在固定大小的页面图纸盒中进行2D嵌套(最大深度为3)矩形盒包装。
要求
一个家庭
tree是一个
树形数据结构,其中每个节点具有任意数量的子代。
首先,充分利用每个页面空间以节省纸张
打印时。
在
breadth-first
秩序,但也要考虑三代人的整体
可能是因为这个家庭将继续成长。
检查内容高度是否超过页面高度
具有特定布局(Page
Model)的工作表框,然后将其删除
已处理的商品,但保留其子代部分属于
处理后将剩余的树数据放置在下一页上。
页面布局看起来像this:
+------------------+------------------+------------------+
| Generation 0 | Generation 1 | Generation 2 |
+------------------+------------------+------------------+
+-- Person A ------+-- Person B ------+-- Person B -- Continue to Page 1 Column 1 Row 2
| unknown | unverifiable | immemorial, Two
| | | sons: Person One
| | | and Person Two.
| | |
| | +-- Person C -- Continue to Page 1 Column 1 Row 3
| | | Two sons: P1
| | | and P2
\ \ \
+------------------+------------------+------------------+
| Generation N + 0 | Generation N + 1 | Generation N + 2 |
+------------------+------------------+------------------+
+-- Person One ----+-- Primo Son -----+-- Primo Grandson -- Continue to Page 2 Column 1 Row 1
| Person One's | Primo Son's | Primo Grandson's
| biography | biography | biography ...
| | |
| | +-- 2th Grandson (childless)
| | | 2th Grandson's
| | | biography ...
| | |
| | +-- 3th Grandson -- Continue to Page 2 Column 1 Row 2
| | | 3th Grandson's
| | | biography ...
| | \
| +-- 2th Son -------+-- Primo Grandson -- Continue to Page 2 Column 1 Row 3
| | 2th Son's | Primo Grandson's
| | biography ... | biography ...
| | \
| +-- 3th Son (childless)
| | 4th Son's
| | biography ...
| \
+-- Person Two (childless)
| Person Two's
| biography
|
|
+-- Person Three --+ Primo Son ------+-- Primo Grandson -- Continue to Page 3 Column 1 Row 1
| Person Three's | Primo Son's | Primo Grandson's
| biography | biography | biography ...
| | \
| +-- 2th Son -------+-- Primo Grandson -- Continue to Page 3 Column 1 Row 2
| | 2th Son's | Primo Grandson's
| | biography ... | biography ...
| | |
| | +-- 2th Grandson (childless)
| | | 2th Grandson's
| | | biography ...
\ \ \
+-- P1 ------------+-- P1-1 ----------+-- P1-1-1 -- Continue to Page 3 Column 1 Row 3
| Person One's | P1-1's | P1-1-1's
| biography | biography | biography ...
| | |
| | +-- P1-1-2 -- Continue to Page 3 Column 1 Row 4
| | | P1-1-2's
| | | biography ...
| \ \
+-- P2 ------------+-- P2-1 ----------+-- P2-1-1 -- Continue to Page 4 Column 1 Row 1
| P2's | P2-1's | P2-1-1's
| biography | biography | biography ...
| | |
| | +-- P2-1-2 -- Continue to Page 4 Column 1 Row 2
| | | P2-1-2's
| | | biography ...
| | \
| +-- P2-2 ----------+-- P2-2-1 -- Continue to Page 4 Column 1 Row 3
| | P2-2's | P2-2-1's
| | biography ... | biography ...
\ \ \
参考
可能是
“级别”表示树中具有相同深度的所有节点
(分组构造)。因此深度是整数
表示从根节点到任何其他节点的相对距离
节点。
所以恕我直言,我将“深度”作为整数值,并将所有节点
具有相同“深度”的元素位于一个“级别”上。
因此,深度是表示相对距离的整数
从根节点到其他任何节点?
族树中树节点的从零开始的深度。