In this section, we present the central result of our paper: a theorem to translate tree decomposition and multilevel graph partitions. Formally, it states:
Our proof is structured as follows: We first describe algorithms to perform the mapping in both directions. Next, we prove that these two algorithms are correct, i.e., that the constructed tree decomposition and multilevel partition fulfill the required properties. Finally, we show that chaining both algorithms is the identity.
4.3. Asymptotic Running Times
The running times of MLP2TD and TD2MLP depend on detailed in-memory representations used for multilevel partitions and tree decompositions. We represent node-based multilevel partition cells in-memory by their separator. Additionally, we store the parent/child relationships among cells. This has the nice property that the amount of storage needed to represent any multilevel partition P is linear in the number of nodes of the graph and the tree. Each cell is the union of its children and its separator. Therefore, the nodes of each cell C can be recovered by a bottom-up traversal that builds the union of the separator of C and all children of C.
Our analysis assumes an implementation that stores a bag X as an array of node IDs. The tree backbone stores for every bag the parent bag’s ID and an array of child bag IDs. Cells are represented as array containing the separator . Further, we store the parent and the children cell’s IDs. In Algorithms 1 and 2, we present two recursive functions that implement MLP2TD and TD2MLP, respectively. We do not explicitly build a tree-backbone or the multilevel partition tree in these functions but just output bags or separators. As both trees are traversed recursively, it is however easy to build them.
|Algorithm 1: Recursive function that implements MLP2TD.|
|Algorithm 2: Recursive function that implements TD2MLP.|
For MLP2TD, we need to calculate the boundary of each cell. OutputBags() in Algorithm 1 recursively calculates the boundary of each cell represented by a separator S. It first calls itself on all children and accumulates their boundaries in B. Then, it marks all nodes in the separator and adds their neighbors to B. Note that marks are global and never cleared. The boundary is then obtained by removing all marked nodes from B. By building the union of S and B, it then outputs the corresponding bag X. To show its correctness, we need to show that OutputBags indeed returns the boundary of the cell represented by S.
In Algorithm 1,OutputBagsreturns the boundary of the cell represented by S.
The proof consists of three steps: First, we show that we obtain a suitable set of candidates on lines 4–9. Then, we show that line 10 removes all nodes that are not in the boundary. As a last step, we show that line 10 does not remove any nodes that are in the boundary.
As a cell C is the union of the children of C and C’s separator, any node in the boundary of C must either be in the boundary of one of C’s children or a neighbor of a node of C’s separator. Therefore, after lines 4–9, B is a superset of the boundary. Further, any node that is in B but not in the boundary is part of C.
Due to the recursive calls of OutputBags, all separators of children of S are marked and thus at least all nodes in C are marked. Therefore, in line 10, all nodes of C are removed.
What remains to be shown is that we have not marked too many nodes. Note that marks are never cleared. We only mark nodes that are contained in a cell that is processed. Thus, any node may be marked unless it is only contained in ancestors of C. Any cell that contains one of C’s boundary nodes touches C and is thus, according to the definition of multilevel partitions, either a descendant or an ancestor of C. As contains a node that is not in C, it must be an ancestor of C. Therefore, is processed after C. This means that no node of the boundary has been marked. □
The running time of Algorithm 1 is linear in the size of the graph and the tree decomposition it computes.
As every node is part of exactly one separator, line 9 is executed exactly once for every node and its total running time is thus linear in the graph. The trickiest step is to implement B in time linear in the final size. For this, we use a combination of an array of size to mark its members and another array that contains the actual elements. We reset the marks at the end of every function call. This allows adding elements without adding duplicates in constant time and then allows to list all elements in time linear in the number of elements. In line 6, we cannot merge the boundary yet but instead first need to store all boundaries as we need the data structure still for the recursive calls. Instead, we merge the boundaries after the loop of recursive calls. Note that we merge every boundary at most once, therefore, the running time is linear in the size of all boundaries combined and thus linear in the output size. □
Algorithm 2 provides a recursive function that implements TD2MLP. Its function OutputSeparators() is called for each bag X recursively, starting with the root bag. OutputSeparators() starts by outputting the nodes in the bag X except nodes that are marked. Then, it marks all nodes in X and calls itself recursively. Algorithm 2 runs in time linear in the input, as it processes the elements of every bag X only a constant number of times. What remains to be shown is that line 4 indeed outputs the separator as defined in TD2MLP.
Line 4 calculates and thus S as defined inTD2MLP.
We need to show that all nodes in are marked and that no nodes in are marked, i.e., that we do not omit any nodes. As all nodes in X are marked in line 5 before the recursive call in line 7, all nodes in are marked when X is processed. However, additional nodes may be marked. We must exclude that there is a node such that but u is marked, i.e., there is a bag Y such that and Y has been processed already. Assume such a node u existed. As the recursion happens after the output, no descendants of X have been processed yet. Therefore, in the backbone tree, the path from X to Y is via . Due to the path requirement, this means that , but we chose u such that . Therefore, such a node u does not exist and therefore we do not remove too many nodes from X and thus line 4 outputs exactly the separator . □
4.4. Example Transformation
The multilevel node-based partition of Figure 4
corresponds to the rooted tree decomposition of Figure 1
b. Consider the left blue cell
. The corresponding bag X
, which is a bag in Figure 1
Alternatively, consider the bag and denote by C the corresponding cell. The parent is the bag . The descendants are . Using the formulas, we obtain . The separator is . We therefore have and thus the cell is .
Finally, let us consider a different example graph. It have three nodes a, b, and c. There are no edges, i.e., the graph is not connected. Further consider a multilevel partition with five cells, namely , , , , and . This translates into a tree decomposition, with two empty bags. corresponds to ∅, and corresponds to ∅, and the cells , , and are equal to their bag. Fortunately, our algorithms also work on this multilevel partition. The two ∅ bags are discerned by their position in the backbone. The children bags of the bag corresponding to the cell are and . The union over all descendants is , which is equal to the original cell . The construction for is analogous. This example shows, that in corner cases, it is important that the sets of bags and cells are multisets.
4.5. Correctness Proof
It remains to formally prove our theorem. In Theorems 2 and 3 in this section, we first show that the two algorithms are correct. In Section 4.6
, we then show that they form a bijection.
Given a multilevel partition,MLP2TDconstructs a rooted tree decomposition with leaf and small bag properties.
We need to show that the three requirements laid out in the tree decomposition definition are fulfilled by the constructed tree decomposition. Further, we need to show that the leaf and the small bag properties hold.
We first show that the node requirement is fulfilled, i.e., that every node is in a bag. A node v in a cell C is either in C’s separator or in a child of C. By applying this observation iteratively and using that the number of cells is finite, we conclude that every node that is in some cell is in some separator. As every cell’s separator is part of its constructed bag, every node in a cell is in a bag. Further, as every node is in the root cell V, we conclude that every node is in some separator and thus in some bag.
Next, we prove that the edge requirement is fulfilled. We need to show that for every edge there exists a bag X such that u and v are part of X. As touching cells are ordered by inclusion, there is a cell that contains u such that no child of contains u. u is in the separator of and thus in the bag corresponding to . Let be analogously a cell that contains v such that no child of contains v. If , then the bag corresponding to is the required X. Otherwise, we observe that the existence of implies that and touch each other. The multilevel partition definition thus requires that and are ordered by inclusion. Assume without loss of generality that . Further, the existence of implies that v is on the boundary of and therefore in the bag corresponding to . The bag corresponding to is therefore the required bag X.
In the next paragraph, we verify that the path requirement holds. We need to show that for every node x and every pair of bags and that include x, x is part of all bags on the path from to . The node x can only be in one cell’s separator. Denote this cell’s bag by . If x is on the boundary of a cell, x is on the boundary or separator of the cell’s parent, and by extension x is part of the cell’s parent’s bag. As x is part of , x is either on the boundary or the separator of the corresponding cell. If it is on the boundary, x is also included in the parent bag of . By applying this argument iteratively, we conclude that x is in all bags of the path from to . Similarly, x is in all bags of the path from to . As is unique, we conclude that all bags on the path from to contain x.
Next, we verify that the leaf property is fulfilled. Denote by C some non-root cell without child and by its parent cell. As C is non-empty by definition and by definition, there exists a node . By definition, as , x is not in the separator of . Further, as x in , it is not on the boundary of . As a consequence, x is part of the bag corresponding to C but not in the bag corresponding to .
Finally, we prove the small bag property. Let X be a bag and x a node in X with the required properties. This means that there is a parent bag such that . Further, we know that no child bag of X contains x. As , x cannot be in the separator of C. x is therefore on the boundary of C. The boundary definition requires, that a node exists such that is an edge. As x is not part of a child bag, x is not on the boundary of any child cell. y can therefore not be part of a child cell. As , y must be part of C’s separator. y is thus not part of . X is therefore the only bag to contain both x and y. Removing x from X would therefore violate the edge requirement. The constructed tree decomposition therefore fulfills the small bag property.
As we have proven all three requirements and both properties, we have proven the theorem. □
The proof that the multilevel partition constructed by TD2MLP is valid is more involved. We therefore organize the proof into several lemmas. Theorem 3 contains the proof that the multilevel partition is valid. Lemmas 5, 6, and 7 are used in the proof of Theorem 3. Lemma 4 exists to prove Lemmas 5, 6, and 7.
Let X be a bag and the set of descendant bags of X. For every node , no bag outside of contains x.
If X is the root bag, then no bag outside of exists and the lemma is trivially true. If X is not the root bag, a parent bag exists. The cell is by definition equal to . A node that is in X and in can therefore not be part of . As , x must be part of . x must therefore be part of a bag Y in . Pick any bag Z outside of . If Z contained x, then the path requirement states that every bag on the path from Y to Z contains x. Both X and are on this path. However, nodes that are in X and cannot be part of . This is a contradiction to . As a consequence, Z cannot exist, which concludes the proof of the lemma. □
Let X and Y be two distinct bags. If Y is an ancestor of X, then .
If Y is the root, then and trivially holds. In the following, assume that Y is not the root and has a parent . Similarly, X has a parent . Further, let and be the descendant bags of X and Y.
By construction, we know that and . As X is a descendant of Y, . To conclude the proof, it is therefore sufficient to show that no node exists that is part of . Suppose that such a node x existed. In this case, x would be part of Y, which is a bag outside of , and thus is a contradiction with Lemma 4. We have thus proven that, if Y is an ancestor of X, then , which concludes the proof. □
If the cells and share a node, then the bags X and Y are in an ancestry relationship.
Denote by x the shared node. From Lemma 4, we deduce that only descendant bags of X contain x. As x is in , we further conclude that there is a descendant bag Z of Y that contains x. This means that Z is a descendant bag of X and of Y. X and Y must therefore be in an ancestry relationship. □
If an edge exists such that and , then the bags X and Y are in an ancestry relationship.
The edge requirement implies that a bag Z exists that contains x and y. Using Lemma 4, we can conclude that Z is a descendant of X as . Similarly, using the same lemma, we can conclude that Z is a descendant of Y as . Z is thus a descendant of X and Y. X and Y are therefore in an ancestry relationship. □
Given a rooted tree decomposition with leaf property,TD2MLPconstructs a multilevel partition.
We need to prove that the constructed multilevel partition fulfills the four multilevel partition requirements. We need to show that the cell corresponding to the root bag is V, that no cell is empty, that touching cells are ordered by inclusion, and that cells that are subset of another cell are in an ancestry relationship.
From the node requirement, we know that every node is in a bag. The cell corresponding to the root bag is defined as the union of all bags. This union is therefore V.
To show that no cell is empty, we need to show that is never empty. We need to show that a node exists that is not part of . There is at least one descendant bag Y of X that is a leaf. The leaf property states that a node exists that is not part of Y’s parent bag . If , then we are finished. Otherwise, is on the path from Y to . As but , it follows from the path property that . However, x is in . We conclude that the cell is not empty.
We show that touching cells are ordered by inclusion. Denote by X and Y two bags corresponding to a pair of touching cells and . As and touch, they share a node or an edge exists with endpoints in and . If they share a node, we conclude using Lemma 6 that X and Y are in an ancestry relationship. Otherwise, if an edge exists with endpoints in and , we conclude using Lemma 7 that X and Y are in an ancestry relationship. From Lemma 5, it follows that, as X and Y are in an ancestry relationship, and are ordered by inclusion.
Finally, we need to show that if , Y is an ancestor of X, and if , X and Y are in an ancestry relationship. If , then the cells share a node and thus using Lemma 6 we conclude that X and Y are in an ancestry relationship. Similarly, we can argue that, if , a node is shared and therefore X and Y are in an ancestry relationship. This means that either Y is a descendant or an ancestor of X. We show by contradiction, that Y is an ancestor. Assume that Y was a descendant. In this case, we can conclude using Lemma 5 that . This is a contradiction with . Y must therefore be an ancestor. □
Theorem 3 requires that the given rooted tree decomposition fulfills the leaf property. This is necessary to prove that the constructed cells are not empty. Fortunately, every rooted tree decomposition can easily be made to fulfill the leaf property by removing the offending and superfluous bags.
4.6. Bijection Proof
We have shown that the MLP2TD and TD2MLP algorithms are correct. It remains to show that the functions described by these algorithms form a bijection. We first show in Lemma 8 that the round trip is safe for multilevel partitions. Later, in Lemma 12, we show the same for tree decompositions.
Let be the multilevel partition obtained by applyingMLP2TDfollowed byTD2MLPto the multilevel partition . Both multilevel partitions are identical, i.e., .
Our proof consists of two parts. We show separately that and .
We first show that implies . Denote by the parent cell of C. As x is in C, x is neither in the separator of nor on the boundary of . x is therefore not in the bag of . As x is in C, x is part of the separator of a descendant cell D of C. x is therefore part of D’s bag. is computed as the union of the descendant bags of C’s bag, which includes D’s bag, minus the intersection of C’s bag and ’s bag. As D’s bag includes x but ’s bag does not, it follows that .
Next, we show that from follows that . Again, denote by the parent cell of C. From , we know that x is in the union of C’s descendants’ bags. x must therefore be in at least one of these bags. Denote by D the cell corresponding to this bag in the input multilevel partition. The bag of D is a subset of the union of C and C’s boundary. If we can show that x is not on the boundary of C, then follows. By construction, we know that x is absent from the intersection of C’s bag with ’s bag. As x is in D and because of the path requirement of tree decompositions, we know that if x was in ’s bag it would also have to be in C’s bag. However, this is a contradiction with x being in the intersection of C’s bag with ’s bag. x is therefore no part of any bag that corresponds to a cell that is not a descendant of C. x is therefore not on the boundary of C. It follows that . □
We have shown that every multilevel partition can be viewed as rooted tree decomposition. The question that remains is whether, every rooted tree decomposition can be viewed as multilevel partition. This only holds if the tree decomposition fulfills the leaf and small bag properties. Fortunately, every rooted tree decomposition can easily be transformed into one that has these properties.
Our proof is organized in several lemmas. Lemma 9 formulates a direct consequence of the small bag property. This consequence is used in the proof of Lemma 10, which shows that holds for multilevel partitions constructed by TD2MLP. Similarly, Lemma 11 shows the same for . Lemma 11 does not require the small bag property. Lemma 12 ties all these Lemmas together. Finally, from Lemmas 8 and 12, the main Theorem 1 directly follows.
In a rooted tree decomposition with small bag property, for every non-root bag X and node x in , there exists a descendant bag Y and an edge such that Y contains x and y but no bag that is not descendant of X contains y.
The small bag property states that x cannot be removed from all descendant bags of X without violating the edge requirement. An edge must therefore exist such that x and y are part of a descendant bag Y of X. Further, x and y cannot both be part of . As , we conclude that . □
Given a rooted tree decomposition with leaf and small bag properties and the multilevel partition constructed byTD2MLP, for every non-root bag X with parent bag and corresponding cell C, the boundary of C is equal to , i.e., .
Denote by X a bag and by C the cell constructed by TD2MLP. C is constructed by TD2MLP as where is the parent of X and is the set descendant bags of X. We prove by showing that and .
We start with an . We need to show that . Using Lemma 9, we know that an edge and a bag Y exists such that , and . As Y is a descendant of X, . Further, as , y is not in . y is therefore in C. x is not in C. As is an edge, x is on the boundary of C, i.e., .
Next, we start with an . We need to show that . As , there must exist an edge such that . From the edge requirement follows, that a bag Y must exist that contains both x and y. As , y is either not in X or not in . In either case, it follows that Y is a descendant bag of X. As , it follows that . As , x is not part of C. x must therefore be in . □
Given a rooted tree decomposition with leaf property and the multilevel partition constructed byTD2MLP, for every non-root bag X with parent bag and corresponding cell C, the separator of C is equal to , i.e., .
Denote by X a bag and by C the cell constructed by TD2MLP. We prove by showing that and .
Start with a node . We need to show that . As X is a descendant of itself, . Denote by Y a child of X and by D the corresponding cell. D is defined as . As , D cannot contain x. As no child cell can contain x and , x must in the separator .
Next, we start with a node . We need to show that . We first show and then . As , we know that . As and , x must be part of a descendant bag Y of X. If , we have shown that . Otherwise, denote by D the cell corresponding to Y. As x is in the separator of C, x cannot be in D. As and , we conclude that x is in . x must thus also be in . If , we have shown that . Otherwise, we repeat the argument for the cell corresponding to and conclude that x is part of the parent bag of . As Y is a descendant of X, we conclude that , by applying this argument iteratively.
Next, we show that . If x was also in , x would be in . x would thus not be in C. However, x is in C and therefore x is not part of . As and , we conclude that . □
Let T be a rooted tree decomposition with leaf and small bag properties. Further, let be the rooted tree decomposition obtained by applyingTD2MLPfollowed byMLP2TDto T. Both tree decompositions are identical, i.e., .
It is clear by construction that the number of bags and cells is always the same. That the root bag and the tree backbone are conserved directly follows from the definition. It remains to show that the contents of the bags are conserved. Denote by X a bag of T and the corresponding bag of . Further, denote by C the intermediate cell. We need to show that . In the first step, we show that the equality holds for all bags except the root bag by showing that and . Afterwards, we show that equality also holds for the root bag.
Start with a node x in X. Either x is in or in . Using Lemmas 10 and 11, we conclude that x is in and , respectively. As is defined as , we conclude that .
Next, we start with a node . We need to show that . As is defined as , x is either in or in . If , we conclude using Lemma 10 that from which follows that . Using Lemma 11, we derive that if , . As x is either in or in , we have shown that .
It remains to be shown that the equality holds for the root bags and with root cell V. By construction, . It remains to be shown that . We need to show that and . Pick . The path requirement implies that for every bag X that contains x either X is the root or the parent of X also contains x. As consequence, no cell except the root cell contains x. follows directly. Next, pick . x is therefore not part of any cell except the root cell. The node requirement implies that x must be part of a bag X. If , then we are finished. Otherwise, x must also be part of X’s part bag as x is not part of X’s corresponding cell. By applying this argument iteratively, we conclude that .
We have shown that for every bag, which concludes the lemma. □
From Lemmas 8 and 12, the main Theorem 1 directly follows. This concludes all proofs in this paper.