在图论中堆叠图论

2023-09-11 04:16:38 作者:^穿著校服拽天下

请帮我找到这个问题的一个很好的解决方案。

Please help me find a good solution for this problem.

我们有n个盒子3的尺寸。我们可以定位他们,我们希望把他们在另一个之上有一个最高可高度。我们可以把上其他盒子上面有个箱子,如果2尺寸(宽和lenght)比下面的框的尺寸降低。

We have n boxes with 3 dimensions. We can orient them and we want to put them on top of another to have a maximun height. We can put a box on top of an other box, if 2 dimensions (width and lenght) are lower than the dimensions of the box below.

有关exapmle我们有3个尺寸宽*深*高,我们就可以在显示它(H * D,D * H,W * D,D * W,H * W,W * H) 请帮我解决这个问题在图论。 在这个问题,我们不能把(2 * 3)上述(2 * 4),因为它具有相同width.so的2维768,16比盒小

For exapmle we have 3 dimensions w*D*h, we can show it in to (h*d,d*h,w*d,d*W,h*w,w*h) please help me to solve it in graph theory. in this problem we can not put(2*3)above(2*4) because it has the same width.so the 2 dimension shoud be smaller than the box

推荐答案

更​​新时(正确的,但可能不是最有效的?):

UPDATED (correct? but possibly not the most efficient):

每个框变为3个顶点(调用相关的这些顶点)。得到一个加权的DAG。这里修改上述算法 排序拓扑(忽略的事实,一些顶点相关),按照算法但不是整数数组记住这导致每个顶点的路径的列表。然后添加路径为一个新的顶点(W在维基ALG)时作出的,导致那里通过丢弃包含有关瓦特一个顶点的路径到v的路径列表。 与原来的算法,一个是指数的。

Each box becomes 3 vertices (call these vertices related). Get a weighted DAG. Modify the algorithm described here Sort topologically (ignoring the fact that some vertices are related), follow the algorithm but instead of array of integers keep a list of the paths that lead to each vertex. Then when adding paths for a new vertex ('w' in wiki alg) make a list of paths that lead there by dropping the paths to v that contain a vertex related to w. Unlike the original algorithm, this one is exponential.

ORIGINAL错误的答案(见注释):

ORIGINAL WRONG ANSWER (see comments):

每个盒子成为其3面大小3个节点。然后创建的每个面连接到更小尺寸的所有表面有向图。分配价格于每一边缘为等于节点(即高度)的第三尺寸的边缘引出。现在,这是寻找最长的路径问题,在一个DAG 的问题。

Each box becomes 3 nodes for its 3 surface sizes. Then create a directed graph connecting each surface to all surfaces of smaller sizes. Assign price to each edge to be equal to the 3rd dimension of the node (i.e. height) that the edge leads to. Now this is the problem of finding the longest path problem in a DAG.