3.4. Conservative Partitioning for Hypergraphs
3.4.3. Avoiding Duplicates
In the following, we present two alternative approaches: Our first approach is more ef- ficient, but produces false negatives. Our second approach produces no false negatives, but has higher processing costs.
Duplicate Avoidance with False Negatives
To prevent the emission of duplicate ccps, MINCUTCONSERVATIVEHYPdistinguishes between two cases: the simple case and the complex case.
The first case occurs if solely a single vertex r is added to C, i.e., |C0\C| = 1. In this case, we can apply the duplicate avoidance technique of MINCUTCONSERVATIVE[12] (Section 2.4), which we now briefly review. The new node r is added to the excluded set X0(Line 17). As a consequence, r cannot be chosen again from the neighborhood (Line 8) in any further child invocation. Additionally, we have to check that X0 is disjoint with C0(Line 12). To see this, imagine a vertex set v with |v| = 1 was merged with X, and in a later iteration of the loop in Line 8, another vertex set u with |u| = 1 is chosen to be merged with C0. Assume that the call toGETCONNECTEDCOMPONENTS
yields O = {O1, O2, ...Ok}. Then, u must be part of some Oi (1 ≤ i ≤ k). Now,
if the previously chosen v is also part of Oi at some recursive call, then only ccps are
emitted that have been emitted before. The check X0∩ C0 6= ∅ prevents this.
The second case is much more complex. We proceed in several steps. In step 1, let us observe that it is easy to generate duplicate ccps. Consider the hypergraph in Figure 3.11 with S = {R0, R1, R2, R3, R4, R5}. Let us forward to the point of the
algorithm’s execution where C = {R0, R1} holds. To continue, we have to recursively
enlarge C with its neighbors. Hence, we have to walk the cycle in the direction C → v → w, which generates C, C ∪ v, C ∪ v ∪ w. The opposite direction gives us C ∪ w, C ∪ w ∪ v. Thus, it is easy to generate duplicate connected components, and because C ∪ v ∪ w would be generated twice, the corresponding ccp (C ∪ v ∪ w, x) would be emitted twice.
PARTITIONM inCutConservativeHyp(H|S)
Input: a connected (sub) hypergraph H|S
Output: all ccp for S 1 for all r ∈ S
2 Xmap[{r}] ← ∅
3 MINCUTCONSERVATIVEHYP(H|S, ∅, ∅, ∅, Xmap, ∅)
MINCUTCONSERVATIVEHYP(H|S, C, Cset, X, Xmap, F )
Input: connected set S, C ∩ X = ∅, F ⊆ C Cseta set<connected sets>
Xmapa map<vertex, set of vertices>
Output: ccps for S 1 if |Cset| = 1 ∧ C 6= S 2 emit (C, S \ C) and (S \ C, C) 3 if |C| = |S| − 1 4 return 5 X0← X 6 X0 map← Xmap 7 F0 ← F N ↓ (S, ∅, ∅) = {arbitrary element of t ∈ S} 8 for all v ∈ N ↓ (S, C, X) : C ∪ v 6= S
9 O ←GETCONNECTEDCOMPONENTS(H|S, C ∪ v)
10 for all Oi∈ O
11 C0 ← S \ Oi
12 if X0∩ C0 6= ∅ ∨ ((C0\ C) ∩ F06= ∅ ∧ ¬
CHECKXMAP(C0, F0, Xmap0 ))
13 continue
14 Cset0 ←MAINTAINCSET(H|S, C, C0, Cset)
15 MINCUTCONSERVATIVEHYP(H|S, C0, Cset0 , X0, Xmap0 , F0)
16 if |v| = 1
17 X0← X0∪ v
18 else
19 F0← F0∪ v
20 X0
map←MAINTAINXMAP(v, Xmap0 )
Figure 3.10.: Pseudocode for MINCUTCONSERVATIVEHYP
R0 R1 R5 R3 R2 R4 C = u = {R0 , R1} v = {R2 , R3} x = {R5} w = {R4}
Figure 3.11.: Sample Hypergraph
In step 2, we convince ourselves that the duplicate avoidance technique of MIN-
CUTCONSERVATIVEdoes not help here. Imagine we have to partition the hypergraph
3.4. Conservative Partitioning for Hypergraphs
N ↓ (S, C, X) with C = {R0, R1} contains v = {R2, R3}. Once v is chosen in Line
8, v is added to C. Assume we apply the technique used in MINCUTCONSERVATIVE. Then we have to add all members of v to X0. Because of R3 ∈ v, that would imply
that we cannot generate C ∪ w ∪ {R3} with w = {R4} later on, which breaks our
correctness constraint (3) (Section 3.4.1).
In step 3, we present our duplicate avoidance strategy. Therefore, we introduce Xmap that represents a mapping between vertices and vertex sets. The mapping is
managed by MAINTAINXMAPpresented in Figure 3.12. Now, instead of adding all vertices of the hypernode v to X0 (case 1), we alter Xmap. We register for every
member of v either (1) the whole hypernode A = v (Line 3 ofMAINTAINXMAP), or (2) merge v with an already registered vertex set (Line 5 ofMAINTAINXMAP).
To check if we are allowed to add {R3} to C (Figure 3.11), we have to consult our
Xmap. This is done by a call toCHECKXMAP(Line 12 of MINCUTCONSERVATIVE-
HYP). Figure 3.13 shows the pseudocode.CHECKXMAPchecks for all vertices r ∈ v
that are added to C if their mapping Xmap[r] is (1) either empty or (2) does not overlap
completely with the new C so that Xmap[r] 6⊆ C holds (Line 2 ofCHECKXMAP). Let
us explain the intuition behind the latter by referring to our example scenario. When we enlarged C = u with v, we set Xmap[R2] = v and Xmap[R3] = v after returning
from the child invocation. In the next iteration of the loop (8 of MINCUTCONSER-
VATIVEHYP), we merge C = u with w. If we now want to add R3 to C = u ∪ w,
CHECKXMAP allows this because Xmap[R3] = v and v \ C 6= ∅ holds. In general,
any combination of vertices in v is allowed to be added to C, as long as not all ele- ments of v are added to C. At that point where we try to add the last member r of v to C as well, Xmap[r] returns v, and since v ⊂ C holds,CHECKXMAPreturnsFALSE.
Since CHECKXMAP ensures that not all members of Xmap[r] are included into C0,
we have to pay attention during the maintenance of Xmap in the case the value of a
given entry Xmap[r] is already assigned with. Before we enlarge Xmap[r] (Line 5 of
MAINTAINXMAP) we have to ensure that Xmap[r] does not already contain A (second
part of the condition in Line 2). For those cases, we have to curtail Xmap[r] (Line 3)
instead of enlarging it. Thus, we allow only for proper subsets of A (and not for the superset Xmap[r] of A) to be added to C in later recursions of MINCUTCONSERVA-
TIVEHYP.
Iterating over all members of C in Line 1 ofCHECKXMAPis relatively expensive. Therefore, we introduce a vertex filter set F . In Line 19 of MINCUTCONSERVATIVE- HYP, we add all elements of a hypernode v to F . It is easy to see that we only need to consider the vertices of C that are also element of F in Line 1 of CHECKXMAP. Furthermore, we can even avoid the whole effort of evaluating CHECKXMAP if all the vertices in C0 \ C with which C is going to be enlarged are disjoint to F (Line 12 of MINCUTCONSERVATIVEHYP). If we assume that the majority of complex hy- peredges are introduced because of non-inner join conflict encodings, the majority of hypergraphs will not have any cycles involving a complex hyperedge and can be cate- gorized as complex cycle-free hypergraphs. In those cases, (C0\ C) ∩ F0 = ∅ holds,
andCHECKXMAPis never called.
As has been said, this approach produces false negatives. Hence, duplicate ccps might be emitted. But these cases are rare. Nevertheless, they result in a performance penalty because of two reasons: First, further unnecessary subcalls to MINCUTCON-
MAINTAINXMAP(A, Xmap)
Input: set A of vertices, Xmapa map<vertex, set of vertices>
Output: modified Xmap
1 for all r ∈ A 2 if Xmap[r] = ∅ ∨ A ⊆ Xmap[r] 3 Xmap[r] ← A 4 else 5 Xmap[r] ← Xmap[r] ∪ A 6 return Xmap
Figure 3.12.: Pseudocode forMAINTAINXMAP
CHECKXMAP(C, F, Xmap)
Input: set C, F , Xmapa map<vertex, set of vertices>
Output:FALSEif duplicate ccps have to be avoided 1 for all r ∈ (C ∩ F )
2 if Xmap[r] 6= ∅ and Xmap[r] \ C = ∅
3 returnFALSE
4 returnTRUE
Figure 3.13.: Pseudocode forCHECKXMAP
And second, false ccps increase the number of iterations of the loop in Lines 2 to 5 of TDPGHYPSUB. Which in turn results in two additional subcalls of TDPGHYP- SUBfor every duplicate ccp. Note that those two invocations will return immediately because the condition of Line 1 of TDPGHYPSUBevaluates toFALSE. With the com- plex hypergraph of Figure 3.14 as input, we give an example where a duplicate ccp is produced through a false negative. Table 3.1 lists all input parameters for each in- vocation of MINCUTCONSERVATIVEHYPexcept for H|S and Cset. In this example,
S will be set to S = {R0, R1, R2, R3, R4, R5}. The first column of Table 3.1 just
serves as entry number for reference. Although C is a vertex set, we display the order of insertion instead of using a set notation (Column 3). For the given S, MINCUT-
CONSERVATIVEHYPemits 19 ccps (symmetric counter pairs not counted), including
one duplicate ccp. Thereby ({R0, R1, R2, R5}, {R3, R4}) is emitted twice, right af-
ter Entry 10 and Entry 19. The call to R0 → R1 → R2 → R5 should have been
avoided (Entry 19). The problem here is that the Xmap entries of R2 and R5 have
each be enlarged by a second hypernode. Xmap[R2] was enlarged by R5 after the
returned call of Entry 12 and Xmap[R5] by R4 after the returned call of Entry 15.
ThusCHECKXMAP(C = {R0, R1, R2, R5}, F = {R2, R3, R4, R5}, Xmap) produced
a false negative and Entry 19 was not prevented.
3.4. Conservative Partitioning for Hypergraphs R0 R1 R3 R5 R4 R2 Figure 3.14.: Hypergraph H(V, E) = ({R0, R1, R2, R3, R4}, {({R0}, {R1}), ({R1}, {R2}), ({R1}, {R3}), ({R1}, {R4}), ({R1}, {R5}), ({R2}, {R4}), ({R3}, {R4}), ({R3}, {R5}), ({R4}, {R5}), ({R0}, {R2, R3}), ({R0}, {R2, R5}), ({R0}, {R4, R5})})
Duplicate Avoidance without False Negatives
As we have seen, the previous technique produces false negatives in some unlikely scenarios. Let us discuss a simple alternative. Therefore, we do not modify the tech- nique as used in MINCUTCONSERVATIVEfor the simple cases where |v| = 1 (Line 8
of MINCUTCONSERVATIVEHYP) holds. But we modify the handling of the complex
cases with |v| > 1. Instead of maintaing a vertex set for every vertex to which we have referred as Xmap, we introduce a set of hypernodes Xset. In case a v with |v| > 1 was
processed (Line 8 of MINCUTCONSERVATIVEHYP) we simple add v to Xset. Now
in order to detect duplicates and avoid unnecessary calls to MINCUTCONSERVATIVE- HYP, we check if C0 ∩ X0 = ∅ holds. This is done as before and covers only the
simple case. For the complex case, we iterate over all entries of h ∈ Xsetand ensure
that C0∩ h = ∅ holds.
Unfortunately, this can become relatively expensive. Therefore, we refine our method. The intuition behind this is that we want to skip the iteration and subsequent checking of complex hypernodes that cannot cause duplicate ccps anyway. We achieve this by adopting our idea of Xmap. This time, Xmapwill contain sets of complex hy-
pernodes. Now once a complex hypernode v is processed, we add v to Xmap[x], where
x ∈ v holds. We determine x by extracting the vertex with the smallest index in v. This is done byMAINTAINXMAPN oF N, as given in Figure 3.15.
In order to decide if a call to MINCUTCONSERVATIVEHYPwill produce duplicate
ccps and, hence, has to be avoided, we have to modify CHECKXMAP as well. We give the pseudocode for our modified version withCHECKXMAPN oF N in Figure 3.16.
Since Xmap[r] now contains a set of complex hypernodes, we have to check each of
them to ensure that none of them is contained in C (Line 3 ofCHECKXMAPN oF N).
As has been said, duplicate ccps produced by the usage of MAINTAINXMAP and
CHECKXMAPare rare. On the other hand,MAINTAINXMAPN oF N andCHECKXMAP
C X Xmap F 1 R0 ∅ empty ∅ 2 R0→R2,R3 ∅ empty ∅ 3 R0→R2,R3→R1 ∅ empty ∅ 4 R0→R2,R3→R1→R4 ∅ empty ∅ 5 R0→R2,R3→R1→R5 {R4} empty ∅ 6 R0→R2,R3→R4 {R1} empty ∅ 7 R0→R2,R3→R4→R5 {R1} empty ∅ 8 R0→R2,R3→R5 {R1,R4} empty ∅ 9 R0→R2,R5 ∅ R2:{R2,R3}, R3:{R2,R3} {R2,R3} 10 R0→R2,R5→R1 ∅ R2:{R2,R3}, R3:{R2,R3} {R2,R3} emitting ({R0, R1, R2, R5}, {R3, R4}) 11 R0→R2,R5→R1→R4 {R3} R2:{R2,R3}, R3:{R2,R3} {R2,R3} 12 R0→R2,R5→R4 {R1,R3} R2:{R2,R3},R3:{R2,R3} {R2,R3} 13 R0→R4,R5 ∅ R2:{R2,R3,R5}, R3:{R2,R3}, {R2,R3, R5:{R2,R5} R5} 14 R0→R4,R5→R1,R3 ∅ R2:{R2,R3,R5}, R3:{R2,R3}, {R2,R3, R5:{R2,R5} R5} 15 R0→R4,R5→R3 {R1,R2} R2:{R2,R3,R5}, R3:{R2,R3}, {R2,R3, R5:{R2,R5} R5} 16 R0→R1 ∅ R2:{R2,R3,R5 },R3:{R2,R3}, {R2,R3, R4:{R4,R5}, R5:{R2,R4,R5} R4,R5} 17 R0→R1→R2 ∅ R2:{R2,R3,R5},R3:{R2,R3}, {R2,R3, R4:{R4,R5}, R5:{R2,R4,R5} R4,R5} 18 R0→R1→R2→R4 {R3} R2:{R2,R3,R5},R3:{R2,R3}, {R2,R3, R4:{R4,R5}, R5:{R2,R4,R5} R4,R5} 19 R0→R1→R2→R5 {R3, R4} R2:{R2,R3,R5},R3:{R2,R3}, {R2,R3, R4:{R4,R5}, R5:{R2,R4,R5} R4,R5} emitting ({R0, R1, R2, R5}, {R3, R4}) 20 R0→R1→R3 {R2} R2:{R2,R3,R5},R3:{R2,R3}, {R2,R3, R4:{R4,R5}, R5:{R2,R4,R5} R4,R5} 21 R0→R1→R3→R5 {R2,R4} R2:{R2,R3,R5 },R3:{R2,R3}, {R2,R3, R4:{R4,R5}, R5:{R2,R4,R5} R4,R5} 22 R0→R1→R5 {R2,R3, R2:{R2,R3,R5},R3:{R2,R3}, {R2,R3, R4} R4:{R4,R5}, R5:{R2,R4,R5} R4,R5}
Table 3.1.: MINCUTCONSERVATIVEHYPemits a duplicate ccp with input of Figure 3.14 and S = {R0, R1, R2, R3, R4, R5}
HYPonly with the former technique and presented the latter only for reasons of com- pleteness.