On the Decomposition of Posets
Prof. Dr. Yangjun Chen
Dept. Applied Computer Science,
University of Winnipeg
515 Portage Ave.
Winnipeg, Manitoba, Canada R3B 2E9
Outline
• Poset and poset decomposition• Applications of poset decomposition
- Evaluation of reachability queries
• Algorithm for poset decomposition- Graph stratification and bipartite graphs- Virtual nodes and virtual edges- Resolution of virtual nodes
• Conclusion
Poset and poset decomposition
A partially ordered set (poset for short) S isa pair (S, ) of a set S and a binary relation such that for each a, b, and c in S:
1.a a is true ( is reflexive),
2.a b and b c imply a c ( is transitive),
3.a b and b a imply a = b ( is antisymmetric).
Example
Poset and poset decomposition
S = (S, )
S = {a, b, c, d, e, f, g, h, i, j, k, l }
d c, d e
g e
l h, l k
b c, b f, b i,
e c, e f, e j,
h a, h k
Any identity such asa = a and transitiverelationship are not shown.
d c, d eg e
l h, l k
b c, b f, b i,
e c, e f, e j,
h a, h k
If we have a poset S = (S, ), a chain in S is a non-empty subset C = {a1, a2, ..., ak} S such that a1 a2 ... ak.
Poset and poset decomposition
Example
b e h
d
g
l
c f i j a k
Example
• Two elements of S are called comparable if they can be put together in some chain in S.
• Elements which are not comparable are called incomparable.
• A non-empty set, in which every pair of elements is not comparable, is called an anti chain.
Poset and poset decomposition
A anti-chain:
{a, c, f, i, j, k}
b e h
d
g
l
c f i j a k
Theorem (Dilworth, 1950) The minimal number of decomposed chains of a poset equals the size of its maximum anti chain.
Poset and poset decomposition
Example
R.P. Dilworth, A decomposition theorem for partially ordered sets, Ann. Math.51 (1950), pp. 161-170.
b e h
d
g
l
c f i j a k
Poset and poset decomposition
“Less clear is how to decompose S into asfew chains as possible.”
A.S. Asratian, T. Denley, and R. Haggkvist,Bipartite Graphs and their Applications,Cambridge University, 1998. (Page 190)
How to decompose S into as few chains as possible?
Applications of poset decompo-tion
Efficient method to evaluate graph reachability queries
- Given a directed acyclic graph (DAG) G, check whether a node v is reachable from another node u through a path in G.- If we can decompose a DAG into a minimum
set of chains, the reachability queries can be efficiently evaluated.
- A DAG can be considered as a poset.
A simple method- store a transitive closure as a matrix
cb
a
d e
G:
cb
a
d e
G*:
M =
abcde
a b c d e00000
10000
10100
00100
10000
M* =
abcde
a b c d e00000
10000
10100
10100
10000
O(n2) spacequery time: O(1)
Applications of poset decompo-tion
Reachability based on poset decomposition
Applications of poset decompo-tion
cb
a
d e
G:
eb
a (1, 1)
(1, 2)
(1, 1)(2, 1)(3, 1)
(1, 2) d
c (2, 1)
(2, 2)
(2, 1)(3, 1)
(2, 2) (3, 1) (3, 1)
• Decompose G into a minimum set of chains.• Each node in G will be assigned an index (i, j) to show that it is
the jth node on the ith chain.• In addition, each node v on the ith chain will be associated with
an index sequence of length : (1, j1) … (i, ji) … (, j) suchthat any node with index (x, y) is a descendant of v if x = iand y j or x i but y jx, where is the minimal number ofthe node-disjoint chains, referred to the as width of G.
Applications of poset decompo-tion
• We can also store all the index sequences as a matrix M, inwhich each entry M(v, j) is the jth element in the indexsequence associated with node v.
• So, a node u with index(u) = (i, j) is a descendant of anothernode v iff M(v, i) j. Thus, using M, a reachability checkingcan be done in O(1) time.
abcde
1 2 3
12___
1_12_
1_1_1
The size of the matrix is O(n).The query time is O(1).
Algorithm for poset decomposition
Graph stratification
Virtual nodes
Resolution of virtual nodes
Graph stratification
Algorithm for poset decomposition
• Let G(V, E) be a DAG. We decompose V into subsets V0, V1
..., Vh such that V = V0 V1 ... Vh and each node in Vi has
its children appearing only in Vi-1, ..., V0 (i = 1, ..., h), where
h is the height of G, i.e., the length of the longest path in G.
• For each node v in Vi, we say, its level is i, denoted l(v) = i.
We also use Cj(v) (j < i) to represent a set of links with each
pointing to one of v’s children, which appears in Vj.
• For each v in Vi, there exist i1, ..., ik (il < i, l = 1, ..., k) such
that the set of its children equals Ci1 ... Cik . Let Vi = {v1,
v2, ..., vl}. We use (j < i) Cji to represent Cj(v1) ... Cj(vl).
C0(b) = {c, f, i} C0(e) = {c, f, j} C0(h) = {a, k}
C1(d) = {e}
C0(d) = {c}
C1(l) = {h}
C0(l) = {k}
C1(g) = {e}
c f i a kj
b e h
d g l
V0:
V1:
V2:
Algorithm for poset decomposition
Graph stratification
b e h
d g l
c f i j a k
Algorithm for poset decomposition
Graph stratification
Algorithm graph-stratification(G)begin1. V0 := all the nodes with no outgoing arcs;2. for i = 0 to h - 1 do3. { W := all the nodes that have at least one child in Vi;4. for each node v in W do5. { let v1, ..., vk be v’s children appearing in Vi;6. Ci(v) := {v1, ..., vk};7. if dout(v) > k then remove v from W;8. G := G\{v v1, ..., v vk};9. dout(v) := dout(v) - k; }10. Vi+1 := W;11. }end
Algorithm for poset decomposition
Bipartite graphs
Definition 1 (bipartite graph) An undirected graphG(V, E) is bipartite if the node set V can bepartitioned into two sets T and S in such a waythat no two nodes from the same set are adjacent.We also denote such a graph as G(T, S; E).
b e h
c f i j a k
b e h
d g l
c f i j a k
Algorithm for poset decomposition
Definition 2 (matching [2]) Let G(V, E) be abipartite graph. A subset of edges E’ E is called amatching if no two edges have a common end node.A matching with the largest possible number ofedges is called a maximal matching, denoted as MG.
M1
:e h
c f i j a k
bb e h
c f i j a k
covered node free node
• A graph stratification can be considered as series ofbipartite graphs.
• We can find a maximum matching for each bipartitegraph, and combine all the maximum matchings toform a set of chains.
Algorithm for poset decomposition
Algorithm for poset decomposition
b e h
c f i j a kV0:
V1:
b e h
d g l
V1:
V2:
b e h
d g lM2:
b e h
d g l
c f i j a k
Combine M1 and M2 to form a set of7 chains:
M1: e h
c f i j a k
b
It is not minimum.
Virtual nodes
Algorithm for poset decomposition
V0’ = V0.Vi’ = Vi {virtual nodes added to Vi} for 1 i h - 1.}Ci = {all the new arcs from the nodes in Vi to the virtualnodes added to Vi-1’} for 1 i h - 1.}G(Vi, Vi-1’; Ci) - the bipartite graph containing Vi and Vi-1’.
Definition 3 (virtual nodes) Let G(V, E) be a DAG, dividedinto V0, ..., Vh (i.e., V = V0 ... Vh). Let Mi be a maximummatching of the bipartite graph G(Vi, Vi-1’; Ci). For each freenode v in Vi-1’ with respect to Mi, a virtual node v’ created forv is a new node added to Vi (1 i h - 1).
Virtual nodes
Algorithm for poset decomposition
M1
:e h
c f i j a k
bb e h
c f i j a k
i’ j’ k’
Virtual arcs
Algorithm for poset decomposition
• The goal of virtual nodes is to establish theconnection between the free nodes (with respectto a certain maximum matching) and the nodesthat may be several levels apart.
• For this purpose, virtual arcs will be used.
inherited arcs - If there is u Vj (j > i) such thatu v E, add u v’, which is not labeled. However,if u v itself is a virtual arc, u v’ will inherit thelabel of u v. In both cases, u v’ is referred to asan inherited arc.
Algorithm for poset decomposition
b e i’ j’ k’h
d g l
V1’:
V2:
l k’ is an inherited arc since in the original graph we have anarc l k.
b e h
d g l
c f i j a k
Algorithm for poset decomposition
transitive arcs - If there exist u w E and w v Ci with u Vj (j > i) and w Vi, add u v’ if it has not yet beencreated as an inherited arc. Such an arc is labeled with andreferred to as a transitive arc (-arc for short).
d j’ and g j’ are two -arcs since j is reachable respectively from d and g through e, a node in V1.
b e i’ j’ k’h
d g l
V1’:
V2:
b e h
d g l
c f i j a k
alternating arcs - If there exist w Vi-1’ such that v is connectedto w through an alternating path, and u Vj (j > i) such thatone of the two conditions holds:- u w E, or- there is a node w’ Vi such that u w’ E and w’ w Ci,
add u v’ if it has not yet been created as an inherited or atransitive arc. We label such an arc with and call it analternating arc (-arc for short).
Algorithm for poset decomposition
an alternating path: f - e - c - b - i and f is reachable from d through a node e in V1.
b e i’ j’ k’h
d g l
V1’:
V2: d i’ and g i’ are two-arcs. We join d and i’since there is a node f thatis connected to i through
an alternating path: f - e - c - b - i and f is reachable from d through a node e in V1.
b e i’ j’ k’h
d g l
V1’:
V2: d i’ and g i’ are two-arcs. We join d and i’since there is a node f thatis connected to i through
Algorithm for poset decomposition
b e h
d g l
c f i j a k
b e h
d g l
c f i j a k
Combine M1 and M2 to form a set of 6 chains:
Algorithm for poset decomposition
b e h
d l g
c f a i j k
i’ j’ k’
b e i’ j’h
d g l
V1’:
V2:
b e i’ j’ k’k’
d l gM2:
b e h
c f i j a kV0:
V1: M1: e h
c f i j a k
b
h
By solving the virtual nodes, we get a set of 6 chains, which do not contain virtual nodes.
Algorithm for poset decomposition
b e h
d
g
l
c f i j a k
b e h
d l g
c f a i j k
i’ j’ k’
Resolution of virtual nodes
Algorithm for poset decomposition
• For resolving virtual nodes, we associate each -arcand -arc with a data structure to facilitate thevirtual node resolution.• The data structure for a -arc e = u v’, denoted
by (e), is a pair of the form <i, {w1, ..., wk}>,where- i is the level number, to which v’ is added,- each wj is connected to v (= s(v’)) through an
alternating path, and- for each wj we have u wj E, or there is a node
w’ Vi such that u w’ E and w’ w Ci.
Algorithm for poset decomposition
Structure of (e):The data structure for the -arc d i’ should be
(d i’) = <1, {c, f}>for the following reason:- i’ is a virtual node added to V1;- c is connected to i through an alternating path c - b - i, and f
is also connected to i through an alternating path:f - e - c - b - i; and
- d c E, and d e E, e f E.
b e i’ j’ k’h
d g l
V1’:
V2:
b e h
d g l
c f i j a k(g i’) is also <1, {c, f}> for the same reason.
Algorithm for poset decomposition
Structure of α(e)
Let v’ be a virtual node created for v, added to Vi.Let e = u v’ be an -arc. Then, there must existw1, ..., wk (k 1) in Vi such that for each wj
(1 j k) u wj E and wj v Ci with u Vl
(for some l > i).
v’w2
u
Vi:
Vl:
w1
wk
v
Algorithm for poset decomposition
For α(e), we distinguish among three cases:
i) There exists wj1, ..., wjp (1 j1 jp k) such that for each wjq (1 q p) wjq v is an arc in the original graph or anunlabeled virtual arc.
ii) Each wj v is neither an arc in the original graph nor anunlabeled virtual arc. However, There exists wj1, ..., wja
(1 j1 ja k) such that for each (1 b a), wjb v isan -arc.
iii) Each wj v is a -arc.
In case (i), the data structure is set to be (e) = <I, >.In case (ii) and (iii), the data structure is set to be (e) = <II,{wj1, ..., wja}> and (e) = <III, {w1, ..., wk}>, respectively.
Example
Algorithm for poset decomposition
b e i’ j’ k’h
d g l
V1’:
V2:
b e h
d g l
c f i j a k
(d j’) = <I, >(g j’) = <I, >
Note that e j is an edgein the original graph.
If e j were an -edge, then (d j’)and (g j’) would be <II, e>.If e j were an -edge, then (d j’)and (g j’) would be <III, e>.
Consider G(Vh, Vh-1’; Ch). Relative to the found maximummatching Mh of it, all the virtual nodes in Vh-1’ can be classifiedinto four groups:
• uncovered (free nodes),• unlabeled-covered,• transitive-covered, and• alternating-covered.
Algorithm for poset decomposition
A virtual node is unlabeled-covered, transitive-covered, oralternating-covered if it is covered by an edge in Mh, whichcorresponds to an unlabeled, transitive, or alternating arc,respectively.
Algorithm for poset decomposition
• Each uncovered virtual node can be simplyremoved.
• But for an unlabeled-covered virtual node v, we willconnect its parent u and its child s(v) (along thecorresponding chain) and then remove v. The newarc u s(v) is handled as unlabeled.
u
v
s(u)
virtual node
unlabeled u
s(u)
unlabeled
Algorithm for poset decomposition
• Resolution of transitive-covered virtual nodes
For u s(v), we need to do two tasks:-Determine whether it is an -arc, a -arc, or
unlabeled.- If it is labeled, figure out the data structure for it.To this end, we will do the following operations:
u
v
s(u)
virtual node
u
s(u)
or ?
1. Let a(u v) be <, W>, where {I, II, III} and W isa subset of Vh-1.
2. Remove v.3. If = I, create an unlabeled arc u s(v). 4. If = II, create an -arc u s(v). Let W = {w1, ..., wk}.
Let (wj s(v)) = <j, Wj> (j = 1, ..., k). If there exists anj such that j = I, set (u s(v)) = <I, >.Otherwise, X := j =IIWj, Y := j =IIIWj.i) If X , set (u s(v)) to be <II, X>.ii) If X = , set (u s(v)) to be <III, Y>.
5. If = III, find W’ W such that for each x W’ (x s(v))is of the form <h - 2, Wx>, where Wx is a subset of nodesin Vh-3’.i) If W’ , create a -arc u s(v) and set
(u s(v)) = <h - 2, >.ii) If W’ = , create an -arc u s(v) and set
(u s(v)) = (u v).
Algorithm for poset decomposition
Algorithm for poset decomposition
• Resolution of alternating-covered virtual nodes
Definition 4 (alternating graph) Let Mi be a maximum matchingof G(Vi, Vi-1’; Ci). The alternating graph with respect to Mi is adirected graph with the following sets of nodes and arcs:
V(Gi) =Vi Vi-1’, and
E(Gi) ={u v | u Vi-1’, v Vi, and (u, v) Mi}
{v u | u Vi-1’, v Vi, and (u, v) Ci\Mi}.
b e h
c f i j a kV0:
V1:
f e c b i
j a h k
In order to resolve all the alternating-covered virtual nodes in Vi’, we combine Gi and Gi+1 by connecting each of these nodes in Vi’ in Gi+1 to some nodes in Vi-1’ in Gi as follows:
Let v1, ..., vk be all those alternating-covered virtual nodes in Vi’ in with b(uj vj) = <i, Wj>, where uj is the parent of vj along the corresponding chain and Wj is a set of nodes in Vi-1’ in Gi.
For each vj, connect vj to every node in Wj (j = 1, ..., k).
We denote such a combined graph by Gi+1 Gi.
Algorithm for poset decomposition
Algorithm for poset decomposition
b e i’ j’ k’h
d g l
V1’:
V2:i’
j’k’
ge
h
d
l
f e c b i
j a h k
b
f e c b i
i’
f ej
i’
c b i
i’
b e h
c f i j a kV0:
V1:
• Let v1 v2 ... vk be a found path.Transfer the arcs on the path.
• If vk is a node in Gi+1, we simply remove thethe corresponding virtual node v1.
• If vk is a node in Gi, connect the parent ofv1 along the corresponding chain to v2.Remove v1.
Algorithm for poset decomposition
Algorithm for poset decomposition
Example
b e h
d
g
l
c f i j a k
b e h
d l g
c f a i j k
i’ j’ k’
f e c b i
i’
b e h
d g l
c f i j a k
b e h
d g l
c f i j a k
Conclusion
• Effiecent Algorithm for the poset decomposition
- Time complexity: O(n2), where is the size of a maximum anti-chain.
- Space complexity: O(n2).
- Graph stratification and Virtual nodes.
- Hopcropt-Karp’s algorithm for finding a maximum matching in a bipartite graph.
• The algorithm can be easily modified to a 0-1 network flow algorithm by defining a chain to be a path.
It will requires O(n2) time and O(n2) space, better than the state-of-the-art 0-1 flow algorithms.
Thank you.