Top Banner
Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente [email protected] Technical University of Catalonia Department of Software E-08034 Barcelona Technical University of Catalonia 1/18 Gabriel Valiente
76

Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Jun 30, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Constrained Tree Inclusion

14th Annual Symposium on Combinatorial Pattern Matching

Gabriel [email protected]

Technical University of Catalonia

Department of Software

E-08034 Barcelona

Technical University of Catalonia 1/18 Gabriel Valiente

Page 2: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Contents

• The tree inclusion problem

• Motivation

• Constrained tree inclusion

• Extension for ordered trees

• Solution for unordered trees

• Related work

Remark The slides got shuffled as the speaker stumbled over a slope whenapproaching the podium

Technical University of Catalonia 2/18 Gabriel Valiente

Page 3: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Contents

• The tree inclusion problem

• Motivation

• Constrained tree inclusion

• Extension for ordered trees

• Solution for unordered trees

• Related work

Remark The slides got shuffled as the speaker stumbled over a slope whenapproaching the podium

Technical University of Catalonia 2/18 Gabriel Valiente

Page 4: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Contents

• The tree inclusion problem

• Motivation

• Constrained tree inclusion

• Extension for ordered trees

• Solution for unordered trees

• Related work

Remark The slides got shuffled as the speaker stumbled over a slope whenapproaching the podium

Technical University of Catalonia 2/18 Gabriel Valiente

Page 5: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Contents

• The tree inclusion problem

• Motivation

• Constrained tree inclusion

• Extension for ordered trees

• Solution for unordered trees

• Related work

Remark The slides got shuffled as the speaker stumbled over a slope whenapproaching the podium

Technical University of Catalonia 2/18 Gabriel Valiente

Page 6: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Contents

• The tree inclusion problem

• Motivation

• Constrained tree inclusion

• Extension for ordered trees

• Solution for unordered trees

• Related work

Remark The slides got shuffled as the speaker stumbled over a slope whenapproaching the podium

Technical University of Catalonia 2/18 Gabriel Valiente

Page 7: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Contents

• The tree inclusion problem

• Motivation

• Constrained tree inclusion

• Extension for ordered trees

• Solution for unordered trees

• Related work

Remark The slides got shuffled as the speaker stumbled over a slope whenapproaching the podium

Technical University of Catalonia 2/18 Gabriel Valiente

Page 8: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Contents

• The tree inclusion problem

• Motivation

• Constrained tree inclusion

• Extension for ordered trees

• Solution for unordered trees

• Related work

Remark The slides got shuffled as the speaker stumbled over a slope whenapproaching the podium

Technical University of Catalonia 2/18 Gabriel Valiente

Page 9: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

The Tree Inclusion Problem

• Given a pattern tree P and a text tree T , both labeled on the nodes, find thesmallest subtrees of T that include P

• Minor containment (deleting nodes and permuting siblings)

T

· · ·

P

· · ·

Technical University of Catalonia 3/18 Gabriel Valiente

Page 10: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

The Tree Inclusion Problem

• Given a pattern tree P and a text tree T , both labeled on the nodes, find thesmallest subtrees of T that include P• Minor containment (deleting nodes and permuting siblings)

T

· · ·

P

· · ·

Technical University of Catalonia 3/18 Gabriel Valiente

Page 11: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

The Tree Inclusion Problem

• Given a pattern tree P and a text tree T , both labeled on the nodes, find thesmallest subtrees of T that include P• Minor containment (deleting nodes and permuting siblings)

T

· · ·

P

· · ·

Technical University of Catalonia 3/18 Gabriel Valiente

Page 12: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

The Tree Inclusion Problem

• Given a pattern tree P and a text tree T , both labeled on the nodes, find thesmallest subtrees of T that include P

• Subtree homeomorphism (deleting degree-two nodes and permutingsiblings)

T

· · ·

P

· · ·

Technical University of Catalonia 4/18 Gabriel Valiente

Page 13: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

The Tree Inclusion Problem

• Given a pattern tree P and a text tree T , both labeled on the nodes, find thesmallest subtrees of T that include P• Subtree homeomorphism (deleting degree-two nodes and permuting

siblings)

T

· · ·

P

· · ·

Technical University of Catalonia 4/18 Gabriel Valiente

Page 14: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

The Tree Inclusion Problem

• Given a pattern tree P and a text tree T , both labeled on the nodes, find thesmallest subtrees of T that include P• Subtree homeomorphism (deleting degree-two nodes and permuting

siblings)

T

· · ·

P

· · ·

Technical University of Catalonia 4/18 Gabriel Valiente

Page 15: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

The Tree Inclusion Problem

• Given a pattern tree P and a text tree T , both labeled on the nodes, find thesmallest subtrees of T that include P

• Subtree isomorphism (deleting degree-one nodes and permutingsiblings)

T

· · ·

P

· · ·

Technical University of Catalonia 5/18 Gabriel Valiente

Page 16: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

The Tree Inclusion Problem

• Given a pattern tree P and a text tree T , both labeled on the nodes, find thesmallest subtrees of T that include P• Subtree isomorphism (deleting degree-one nodes and permuting

siblings)

T

· · ·

P

· · ·

Technical University of Catalonia 5/18 Gabriel Valiente

Page 17: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

The Tree Inclusion Problem

• Given a pattern tree P and a text tree T , both labeled on the nodes, find thesmallest subtrees of T that include P• Subtree isomorphism (deleting degree-one nodes and permuting

siblings)

T

· · ·

P

· · ·

Technical University of Catalonia 5/18 Gabriel Valiente

Page 18: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

The Tree Inclusion Problem

• Given a pattern tree P and a text tree T , both labeled on the nodes, find thesmallest subtrees of T that include P

• Constrained tree inclusion (deleting degree-one and degree-two nodesand permuting siblings)

T

· · ·

P

· · ·

Technical University of Catalonia 6/18 Gabriel Valiente

Page 19: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

The Tree Inclusion Problem

• Given a pattern tree P and a text tree T , both labeled on the nodes, find thesmallest subtrees of T that include P• Constrained tree inclusion (deleting degree-one and degree-two nodes

and permuting siblings)

T

· · ·

P

· · ·

Technical University of Catalonia 6/18 Gabriel Valiente

Page 20: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

The Tree Inclusion Problem

• Given a pattern tree P and a text tree T , both labeled on the nodes, find thesmallest subtrees of T that include P• Constrained tree inclusion (deleting degree-one and degree-two nodes

and permuting siblings)

T

· · ·

P

· · ·

Technical University of Catalonia 6/18 Gabriel Valiente

Page 21: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Motivation

• Constrained tree inclusion is motivated by the study of query languages forstructured text databases

• Tree inclusion has two main drawbacks• The solution to a tree inclusion query of a pattern tree in a text tree is

not much sensitive to the structure of the query: Many structuralforms of the same pattern may be included in the same text tree

• Complexity of tree inclusion• NP-hard for unordered trees• Solvable for ordered trees by dynamic programming in O(mn)

time and space, in the worst case and also on the average

• These drawbacks stem from the generality of tree inclusion

Technical University of Catalonia 7/18 Gabriel Valiente

Page 22: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Motivation

• Constrained tree inclusion is motivated by the study of query languages forstructured text databases

• Tree inclusion has two main drawbacks

• The solution to a tree inclusion query of a pattern tree in a text tree isnot much sensitive to the structure of the query: Many structuralforms of the same pattern may be included in the same text tree

• Complexity of tree inclusion• NP-hard for unordered trees• Solvable for ordered trees by dynamic programming in O(mn)

time and space, in the worst case and also on the average

• These drawbacks stem from the generality of tree inclusion

Technical University of Catalonia 7/18 Gabriel Valiente

Page 23: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Motivation

• Constrained tree inclusion is motivated by the study of query languages forstructured text databases

• Tree inclusion has two main drawbacks• The solution to a tree inclusion query of a pattern tree in a text tree is

not much sensitive to the structure of the query: Many structuralforms of the same pattern may be included in the same text tree

• Complexity of tree inclusion• NP-hard for unordered trees• Solvable for ordered trees by dynamic programming in O(mn)

time and space, in the worst case and also on the average

• These drawbacks stem from the generality of tree inclusion

Technical University of Catalonia 7/18 Gabriel Valiente

Page 24: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Motivation

• Constrained tree inclusion is motivated by the study of query languages forstructured text databases

• Tree inclusion has two main drawbacks• The solution to a tree inclusion query of a pattern tree in a text tree is

not much sensitive to the structure of the query: Many structuralforms of the same pattern may be included in the same text tree

• Complexity of tree inclusion

• NP-hard for unordered trees• Solvable for ordered trees by dynamic programming in O(mn)

time and space, in the worst case and also on the average

• These drawbacks stem from the generality of tree inclusion

Technical University of Catalonia 7/18 Gabriel Valiente

Page 25: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Motivation

• Constrained tree inclusion is motivated by the study of query languages forstructured text databases

• Tree inclusion has two main drawbacks• The solution to a tree inclusion query of a pattern tree in a text tree is

not much sensitive to the structure of the query: Many structuralforms of the same pattern may be included in the same text tree

• Complexity of tree inclusion• NP-hard for unordered trees

• Solvable for ordered trees by dynamic programming in O(mn)time and space, in the worst case and also on the average

• These drawbacks stem from the generality of tree inclusion

Technical University of Catalonia 7/18 Gabriel Valiente

Page 26: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Motivation

• Constrained tree inclusion is motivated by the study of query languages forstructured text databases

• Tree inclusion has two main drawbacks• The solution to a tree inclusion query of a pattern tree in a text tree is

not much sensitive to the structure of the query: Many structuralforms of the same pattern may be included in the same text tree

• Complexity of tree inclusion• NP-hard for unordered trees• Solvable for ordered trees by dynamic programming in O(mn)

time and space, in the worst case and also on the average

• These drawbacks stem from the generality of tree inclusion

Technical University of Catalonia 7/18 Gabriel Valiente

Page 27: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Motivation

• Constrained tree inclusion is motivated by the study of query languages forstructured text databases

• Tree inclusion has two main drawbacks• The solution to a tree inclusion query of a pattern tree in a text tree is

not much sensitive to the structure of the query: Many structuralforms of the same pattern may be included in the same text tree

• Complexity of tree inclusion• NP-hard for unordered trees• Solvable for ordered trees by dynamic programming in O(mn)

time and space, in the worst case and also on the average

• These drawbacks stem from the generality of tree inclusion

Technical University of Catalonia 7/18 Gabriel Valiente

Page 28: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Motivation

• Three forms of the same query are all included at the node labeled A in thetext tree, shown to the right of the picture

A

B C D E

A

B

C D E

A

B

C

D E

A

B

C

D E

Technical University of Catalonia 8/18 Gabriel Valiente

Page 29: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Constrained Tree Inclusion

• A tree P is included in a tree T , denoted by P v T , if there is a sequence ofnodes v1,v2, . . . ,vk in V (T ) such that

• Ti+1∼= delete(Ti,vi+1)

• outdeg(Ti,vi+1) 6 1for 1 6 i 6 k−1, with T0 = T and Tk = P

• P v T , because P can be obtained from T by deleting degree-one anddegree-two nodes, as shown from right to left

A z

P = T2 ∼= delete(T1,y)

x B C v

A z

T1 ∼= delete(T0,w)

y

x B

C v

A z

T0 = T

v C y

w B x

Technical University of Catalonia 9/18 Gabriel Valiente

Page 30: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Constrained Tree Inclusion

• A tree P is included in a tree T , denoted by P v T , if there is a sequence ofnodes v1,v2, . . . ,vk in V (T ) such that

• Ti+1∼= delete(Ti,vi+1)

• outdeg(Ti,vi+1) 6 1for 1 6 i 6 k−1, with T0 = T and Tk = P

• P v T , because P can be obtained from T by deleting degree-one anddegree-two nodes, as shown from right to left

A z

P = T2 ∼= delete(T1,y)

x B C v

A z

T1 ∼= delete(T0,w)

y

x B

C v

A z

T0 = T

v C y

w B x

Technical University of Catalonia 9/18 Gabriel Valiente

Page 31: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Constrained Tree Inclusion

• A tree P is included in a tree T , denoted by P v T , if there is a sequence ofnodes v1,v2, . . . ,vk in V (T ) such that

• Ti+1∼= delete(Ti,vi+1)

• outdeg(Ti,vi+1) 6 1

for 1 6 i 6 k−1, with T0 = T and Tk = P

• P v T , because P can be obtained from T by deleting degree-one anddegree-two nodes, as shown from right to left

A z

P = T2 ∼= delete(T1,y)

x B C v

A z

T1 ∼= delete(T0,w)

y

x B

C v

A z

T0 = T

v C y

w B x

Technical University of Catalonia 9/18 Gabriel Valiente

Page 32: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Constrained Tree Inclusion

• A tree P is included in a tree T , denoted by P v T , if there is a sequence ofnodes v1,v2, . . . ,vk in V (T ) such that

• Ti+1∼= delete(Ti,vi+1)

• outdeg(Ti,vi+1) 6 1for 1 6 i 6 k−1, with T0 = T and Tk = P

• P v T , because P can be obtained from T by deleting degree-one anddegree-two nodes, as shown from right to left

A z

P = T2 ∼= delete(T1,y)

x B C v

A z

T1 ∼= delete(T0,w)

y

x B

C v

A z

T0 = T

v C y

w B x

Technical University of Catalonia 9/18 Gabriel Valiente

Page 33: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Constrained Tree Inclusion

• A tree P is included in a tree T , denoted by P v T , if there is a sequence ofnodes v1,v2, . . . ,vk in V (T ) such that

• Ti+1∼= delete(Ti,vi+1)

• outdeg(Ti,vi+1) 6 1for 1 6 i 6 k−1, with T0 = T and Tk = P

• P v T , because P can be obtained from T by deleting degree-one anddegree-two nodes, as shown from right to left

A z

P = T2 ∼= delete(T1,y)

x B C v

A z

T1 ∼= delete(T0,w)

y

x B

C v

A z

T0 = T

v C y

w B x

Technical University of Catalonia 9/18 Gabriel Valiente

Page 34: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Constrained Tree Inclusion

• A tree P is included in a tree T , denoted by P v T , if there is a sequence ofnodes v1,v2, . . . ,vk in V (T ) such that

• Ti+1∼= delete(Ti,vi+1)

• outdeg(Ti,vi+1) 6 1for 1 6 i 6 k−1, with T0 = T and Tk = P

• P v T , because P can be obtained from T by deleting degree-one anddegree-two nodes, as shown from right to left

A z

P = T2 ∼= delete(T1,y)

x B C v

A z

T1 ∼= delete(T0,w)

y

x B

C v

A z

T0 = T

v C y

w B x

Technical University of Catalonia 9/18 Gabriel Valiente

Page 35: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Constrained Tree Inclusion

• The number of pattern trees that are included in a text tree is exponential inthe size of the text tree

includes

and does not include

Technical University of Catalonia 10/18 Gabriel Valiente

Page 36: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Constrained Tree Inclusion

• The number of pattern trees that are included in a text tree is exponential inthe size of the text tree

includes

and does not include

Technical University of Catalonia 10/18 Gabriel Valiente

Page 37: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Constrained Tree Inclusion

• The key to an efficient solution lies in the fact that a constrained treeinclusion problem instance can be decomposed into a series of smaller,independent problem instances

• In order to determine whether or not P[v]v T [w] it suffices to know ifP[v]v T [y] and if P[x]v T [y] for all children x of v and all children y of w

P[v]

P[v1] P[v2] · · · P[vp]

T [w]

T [w1] T [w2] · · · T [wt ]

• That is, it suffices to know if P[x]v T [y] for all x ∈ {v,v1,v2, . . . ,vp} andy ∈ {w1,w2, . . . ,wt}

Technical University of Catalonia 11/18 Gabriel Valiente

Page 38: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Constrained Tree Inclusion

• The key to an efficient solution lies in the fact that a constrained treeinclusion problem instance can be decomposed into a series of smaller,independent problem instances

• In order to determine whether or not P[v]v T [w] it suffices to know ifP[v]v T [y] and if P[x]v T [y] for all children x of v and all children y of w

P[v]

P[v1] P[v2] · · · P[vp]

T [w]

T [w1] T [w2] · · · T [wt ]

• That is, it suffices to know if P[x]v T [y] for all x ∈ {v,v1,v2, . . . ,vp} andy ∈ {w1,w2, . . . ,wt}

Technical University of Catalonia 11/18 Gabriel Valiente

Page 39: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Constrained Tree Inclusion

• The key to an efficient solution lies in the fact that a constrained treeinclusion problem instance can be decomposed into a series of smaller,independent problem instances

• In order to determine whether or not P[v]v T [w] it suffices to know ifP[v]v T [y] and if P[x]v T [y] for all children x of v and all children y of w

P[v]

P[v1]

P[v2] · · ·

P[vp]

T [w]�

T [w1]

T [w2] · · ·

T [wt ]

• That is, it suffices to know if P[x]v T [y] for all x ∈ {v,v1,v2, . . . ,vp} andy ∈ {w1,w2, . . . ,wt}

Technical University of Catalonia 11/18 Gabriel Valiente

Page 40: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Constrained Tree Inclusion

• The key to an efficient solution lies in the fact that a constrained treeinclusion problem instance can be decomposed into a series of smaller,independent problem instances

• In order to determine whether or not P[v]v T [w] it suffices to know ifP[v]v T [y] and if P[x]v T [y] for all children x of v and all children y of w

P[v]

P[v1]

P[v2] · · ·

P[vp]

T [w]�

T [w1]

T [w2] · · ·

T [wt ]

• That is, it suffices to know if P[x]v T [y] for all x ∈ {v,v1,v2, . . . ,vp} andy ∈ {w1,w2, . . . ,wt}

Technical University of Catalonia 11/18 Gabriel Valiente

Page 41: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Extension for Ordered Trees

• An ordered bipartite graph is a bipartite graph G = (V ∪W,E) withorderings V = (v1,v2, . . . ,vp) and W = (w1,w2, . . . ,wq)

• A noncrossing matching M in an ordered bipartite graph G = (V ∪W,E) isa subset of edges M ⊆ E such that no two edges are incident to the samevertex and no two edges are crossing, that is, for all edges (vi,wk) and(v j,w`) in M, i < j if and only if k < `

• The decision problem of whether an ordered bipartite graph (V ∪W,E) hasa noncrossing matching of size |W | can be solved in O(n) time

• Given an ordered bipartite graph (V ∪W,E), the greedy strategy of alwayschoosing the first noncrossing edge joining some vertex vi ∈V with vertexw j ∈W , for 1 6 j 6 |W |, gives a noncrossing matching with |W | edges, aslong as such a matching does exist

• Noncrossing bipartite matching is equivalent to sequence inclusion

Technical University of Catalonia 12/18 Gabriel Valiente

Page 42: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Extension for Ordered Trees

• An ordered bipartite graph is a bipartite graph G = (V ∪W,E) withorderings V = (v1,v2, . . . ,vp) and W = (w1,w2, . . . ,wq)

• A noncrossing matching M in an ordered bipartite graph G = (V ∪W,E) isa subset of edges M ⊆ E such that no two edges are incident to the samevertex and no two edges are crossing, that is, for all edges (vi,wk) and(v j,w`) in M, i < j if and only if k < `

• The decision problem of whether an ordered bipartite graph (V ∪W,E) hasa noncrossing matching of size |W | can be solved in O(n) time

• Given an ordered bipartite graph (V ∪W,E), the greedy strategy of alwayschoosing the first noncrossing edge joining some vertex vi ∈V with vertexw j ∈W , for 1 6 j 6 |W |, gives a noncrossing matching with |W | edges, aslong as such a matching does exist

• Noncrossing bipartite matching is equivalent to sequence inclusion

Technical University of Catalonia 12/18 Gabriel Valiente

Page 43: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Extension for Ordered Trees

• An ordered bipartite graph is a bipartite graph G = (V ∪W,E) withorderings V = (v1,v2, . . . ,vp) and W = (w1,w2, . . . ,wq)

• A noncrossing matching M in an ordered bipartite graph G = (V ∪W,E) isa subset of edges M ⊆ E such that no two edges are incident to the samevertex and no two edges are crossing, that is, for all edges (vi,wk) and(v j,w`) in M, i < j if and only if k < `

• The decision problem of whether an ordered bipartite graph (V ∪W,E) hasa noncrossing matching of size |W | can be solved in O(n) time

• Given an ordered bipartite graph (V ∪W,E), the greedy strategy of alwayschoosing the first noncrossing edge joining some vertex vi ∈V with vertexw j ∈W , for 1 6 j 6 |W |, gives a noncrossing matching with |W | edges, aslong as such a matching does exist

• Noncrossing bipartite matching is equivalent to sequence inclusion

Technical University of Catalonia 12/18 Gabriel Valiente

Page 44: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Extension for Ordered Trees

• An ordered bipartite graph is a bipartite graph G = (V ∪W,E) withorderings V = (v1,v2, . . . ,vp) and W = (w1,w2, . . . ,wq)

• A noncrossing matching M in an ordered bipartite graph G = (V ∪W,E) isa subset of edges M ⊆ E such that no two edges are incident to the samevertex and no two edges are crossing, that is, for all edges (vi,wk) and(v j,w`) in M, i < j if and only if k < `

• The decision problem of whether an ordered bipartite graph (V ∪W,E) hasa noncrossing matching of size |W | can be solved in O(n) time

• Given an ordered bipartite graph (V ∪W,E), the greedy strategy of alwayschoosing the first noncrossing edge joining some vertex vi ∈V with vertexw j ∈W , for 1 6 j 6 |W |, gives a noncrossing matching with |W | edges, aslong as such a matching does exist

• Noncrossing bipartite matching is equivalent to sequence inclusion

Technical University of Catalonia 12/18 Gabriel Valiente

Page 45: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Extension for Ordered Trees

• An ordered bipartite graph is a bipartite graph G = (V ∪W,E) withorderings V = (v1,v2, . . . ,vp) and W = (w1,w2, . . . ,wq)

• A noncrossing matching M in an ordered bipartite graph G = (V ∪W,E) isa subset of edges M ⊆ E such that no two edges are incident to the samevertex and no two edges are crossing, that is, for all edges (vi,wk) and(v j,w`) in M, i < j if and only if k < `

• The decision problem of whether an ordered bipartite graph (V ∪W,E) hasa noncrossing matching of size |W | can be solved in O(n) time

• Given an ordered bipartite graph (V ∪W,E), the greedy strategy of alwayschoosing the first noncrossing edge joining some vertex vi ∈V with vertexw j ∈W , for 1 6 j 6 |W |, gives a noncrossing matching with |W | edges, aslong as such a matching does exist

• Noncrossing bipartite matching is equivalent to sequence inclusion

Technical University of Catalonia 12/18 Gabriel Valiente

Page 46: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Extension for Ordered Trees

• Time complexity is dominated by the solution of a series of smallnoncrossing bipartite matching problems

n

∑i=1

m

∑j=1

O(outdeg(wi)outdeg(v j)) =n

∑i=1

O(m ·outdeg(wi)) = O(mn)

Technical University of Catalonia 13/18 Gabriel Valiente

Page 47: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Extension for Ordered Trees

• Time complexity is dominated by the solution of a series of smallnoncrossing bipartite matching problems

n

∑i=1

m

∑j=1

O(outdeg(wi)outdeg(v j)) =n

∑i=1

O(m ·outdeg(wi)) = O(mn)

Technical University of Catalonia 13/18 Gabriel Valiente

Page 48: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• For all w ∈V (T ), let S(w) = {v ∈V (P) | P[v]v T [w]}

• For all nodes v ∈V (P) and w ∈V (T ), P[v]v T [w] if and only if v ∈ S(w)

• P v T if and only if {w ∈V (T ) | root(P) ∈ S(w)} 6= /0• There is a sequence of node deletion operations that transform any given

tree T into the tree T ′ with V (T ′) = {root(T )} and E(T ′) = /0By deleting all nonroot nodes of T in postorder, the children (if any) of anode will have already been deleted when the node is considered fordeletion, meaning the node has become a degree-one node (a leaf), whichcan thus be deleted

Technical University of Catalonia 14/18 Gabriel Valiente

Page 49: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• For all w ∈V (T ), let S(w) = {v ∈V (P) | P[v]v T [w]}• For all nodes v ∈V (P) and w ∈V (T ), P[v]v T [w] if and only if v ∈ S(w)

• P v T if and only if {w ∈V (T ) | root(P) ∈ S(w)} 6= /0• There is a sequence of node deletion operations that transform any given

tree T into the tree T ′ with V (T ′) = {root(T )} and E(T ′) = /0By deleting all nonroot nodes of T in postorder, the children (if any) of anode will have already been deleted when the node is considered fordeletion, meaning the node has become a degree-one node (a leaf), whichcan thus be deleted

Technical University of Catalonia 14/18 Gabriel Valiente

Page 50: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• For all w ∈V (T ), let S(w) = {v ∈V (P) | P[v]v T [w]}• For all nodes v ∈V (P) and w ∈V (T ), P[v]v T [w] if and only if v ∈ S(w)

• P v T if and only if {w ∈V (T ) | root(P) ∈ S(w)} 6= /0

• There is a sequence of node deletion operations that transform any giventree T into the tree T ′ with V (T ′) = {root(T )} and E(T ′) = /0By deleting all nonroot nodes of T in postorder, the children (if any) of anode will have already been deleted when the node is considered fordeletion, meaning the node has become a degree-one node (a leaf), whichcan thus be deleted

Technical University of Catalonia 14/18 Gabriel Valiente

Page 51: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• For all w ∈V (T ), let S(w) = {v ∈V (P) | P[v]v T [w]}• For all nodes v ∈V (P) and w ∈V (T ), P[v]v T [w] if and only if v ∈ S(w)

• P v T if and only if {w ∈V (T ) | root(P) ∈ S(w)} 6= /0• There is a sequence of node deletion operations that transform any given

tree T into the tree T ′ with V (T ′) = {root(T )} and E(T ′) = /0

By deleting all nonroot nodes of T in postorder, the children (if any) of anode will have already been deleted when the node is considered fordeletion, meaning the node has become a degree-one node (a leaf), whichcan thus be deleted

Technical University of Catalonia 14/18 Gabriel Valiente

Page 52: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• For all w ∈V (T ), let S(w) = {v ∈V (P) | P[v]v T [w]}• For all nodes v ∈V (P) and w ∈V (T ), P[v]v T [w] if and only if v ∈ S(w)

• P v T if and only if {w ∈V (T ) | root(P) ∈ S(w)} 6= /0• There is a sequence of node deletion operations that transform any given

tree T into the tree T ′ with V (T ′) = {root(T )} and E(T ′) = /0By deleting all nonroot nodes of T in postorder, the children (if any) of anode will have already been deleted when the node is considered fordeletion, meaning the node has become a degree-one node (a leaf), whichcan thus be deleted

Technical University of Catalonia 14/18 Gabriel Valiente

Page 53: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• P[v]v T [parent(w)] if P[v]v T [w], for all nodes v ∈V (P) and all nonrootnodes w ∈V (T )

T [parent(w)]

T [xi] · · · T [x j] T [w] T [xk] · · · T [x`]

P[v]v T [w], and T [w] can be obtained from T [parent(w)] by deleting T [x]for all siblings x of node w and, then, deleting node parent(w), which hasbecome either a degree-one or a degree-two node

Technical University of Catalonia 15/18 Gabriel Valiente

Page 54: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• P[v]v T [parent(w)] if P[v]v T [w], for all nodes v ∈V (P) and all nonrootnodes w ∈V (T )

T [parent(w)]

T [xi] · · ·

T [x j]

T [w]�

T [xk] · · ·

T [x`]

P[v]v T [w], and T [w] can be obtained from T [parent(w)] by deleting T [x]for all siblings x of node w and, then, deleting node parent(w), which hasbecome either a degree-one or a degree-two node

Technical University of Catalonia 15/18 Gabriel Valiente

Page 55: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• P[v]v T [parent(w)] if P[v]v T [w], for all nodes v ∈V (P) and all nonrootnodes w ∈V (T )

T [parent(w)]

T [xi] · · ·

T [x j]

T [w]�

T [xk] · · ·

T [x`]

P[v]v T [w], and T [w] can be obtained from T [parent(w)] by deleting T [x]for all siblings x of node w and, then, deleting node parent(w), which hasbecome either a degree-one or a degree-two node

Technical University of Catalonia 15/18 Gabriel Valiente

Page 56: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• Let v ∈V (P) have children v1,v2, . . . ,vp, and let w ∈V (T ) have childrenw1,w2, . . . ,wt . Then, P[v]v T [w] if and only if either there is a child w j ofw such that P[v]v T [w j], or label(v) = label(w) and there is a subset of pdifferent nodes {u1,u2, . . . ,up} ⊆ {w1,w2, . . . ,wt} such that P[vi]v T [ui]for 1 6 i 6 p

T [w]

T [w1] · · · T [w j−1] T [w j] T [w j+1] · · · T [wt ]

In the first case, P[v] can be obtained from T [w] by deletingT [w1],T [w2], . . . ,T [w j−1],T [w j+1], . . . ,T [wt ] and, then, deleting node w,which has become either a degree-one or a degree-two node

In the second case, P[v] can be obtained from T [w] by deleting T [wi] for allwi ∈ {w1,w2, . . . ,wt}\{u1,u2, . . . ,up}

Technical University of Catalonia 16/18 Gabriel Valiente

Page 57: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• Let v ∈V (P) have children v1,v2, . . . ,vp, and let w ∈V (T ) have childrenw1,w2, . . . ,wt . Then, P[v]v T [w] if and only if either there is a child w j ofw such that P[v]v T [w j], or label(v) = label(w) and there is a subset of pdifferent nodes {u1,u2, . . . ,up} ⊆ {w1,w2, . . . ,wt} such that P[vi]v T [ui]for 1 6 i 6 p

T [w]

T [w1] · · ·

T [w j−1]�

T [w j]

T [w j+1] · · ·

T [wt ]

In the first case, P[v] can be obtained from T [w] by deletingT [w1],T [w2], . . . ,T [w j−1],T [w j+1], . . . ,T [wt ] and, then, deleting node w,which has become either a degree-one or a degree-two node

In the second case, P[v] can be obtained from T [w] by deleting T [wi] for allwi ∈ {w1,w2, . . . ,wt}\{u1,u2, . . . ,up}

Technical University of Catalonia 16/18 Gabriel Valiente

Page 58: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• Let v ∈V (P) have children v1,v2, . . . ,vp, and let w ∈V (T ) have childrenw1,w2, . . . ,wt . Then, P[v]v T [w] if and only if either there is a child w j ofw such that P[v]v T [w j], or label(v) = label(w) and there is a subset of pdifferent nodes {u1,u2, . . . ,up} ⊆ {w1,w2, . . . ,wt} such that P[vi]v T [ui]for 1 6 i 6 p

T [w]

T [w1] · · ·

T [w j−1]�

T [w j]

T [w j+1] · · ·

T [wt ]

In the first case, P[v] can be obtained from T [w] by deletingT [w1],T [w2], . . . ,T [w j−1],T [w j+1], . . . ,T [wt ] and, then, deleting node w,which has become either a degree-one or a degree-two node

In the second case, P[v] can be obtained from T [w] by deleting T [wi] for allwi ∈ {w1,w2, . . . ,wt}\{u1,u2, . . . ,up}

Technical University of Catalonia 16/18 Gabriel Valiente

Page 59: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• Let v ∈V (P) have children v1,v2, . . . ,vp, and let w ∈V (T ) have childrenw1,w2, . . . ,wt . Then, P[v]v T [w] if and only if either there is a child w j ofw such that P[v]v T [w j], or label(v) = label(w) and there is a subset of pdifferent nodes {u1,u2, . . . ,up} ⊆ {w1,w2, . . . ,wt} such that P[vi]v T [ui]for 1 6 i 6 p

T [w]

T [w1] · · ·

T [w j−1]�

T [w j]

T [w j+1] · · ·

T [wt ]

In the first case, P[v] can be obtained from T [w] by deletingT [w1],T [w2], . . . ,T [w j−1],T [w j+1], . . . ,T [wt ] and, then, deleting node w,which has become either a degree-one or a degree-two node

In the second case, P[v] can be obtained from T [w] by deleting T [wi] for allwi ∈ {w1,w2, . . . ,wt}\{u1,u2, . . . ,up}

Technical University of Catalonia 16/18 Gabriel Valiente

Page 60: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• A similar result was enunciated without proof in [Chung, 1987] for thesubtree homeomorphism problem but does not carry over to constrainedtree inclusion (it does not even hold for subtree homeomorphism) becausedeletion of degree-one nodes, not only of degree-two nodes, is required

• The set of included subtrees S(w) can be computed for each nodew ∈V (T ) in a bottom-up way

• Time complexity is dominated by the solution of a series of smallmaximum bipartite matching problems

n

∑i=1

m

∑j=1

O(outdeg(wi)outdeg(v j)1.5)

=n

∑i=1

O(m1.5outdeg(wi)) (becausem

∑j=1

outdeg(v j) = m−1)

= O(m1.5n) (becausen

∑i=1

outdeg(wi) = n−1)

Technical University of Catalonia 17/18 Gabriel Valiente

Page 61: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• A similar result was enunciated without proof in [Chung, 1987] for thesubtree homeomorphism problem but does not carry over to constrainedtree inclusion (it does not even hold for subtree homeomorphism) becausedeletion of degree-one nodes, not only of degree-two nodes, is required

• The set of included subtrees S(w) can be computed for each nodew ∈V (T ) in a bottom-up way

• Time complexity is dominated by the solution of a series of smallmaximum bipartite matching problems

n

∑i=1

m

∑j=1

O(outdeg(wi)outdeg(v j)1.5)

=n

∑i=1

O(m1.5outdeg(wi)) (becausem

∑j=1

outdeg(v j) = m−1)

= O(m1.5n) (becausen

∑i=1

outdeg(wi) = n−1)

Technical University of Catalonia 17/18 Gabriel Valiente

Page 62: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• A similar result was enunciated without proof in [Chung, 1987] for thesubtree homeomorphism problem but does not carry over to constrainedtree inclusion (it does not even hold for subtree homeomorphism) becausedeletion of degree-one nodes, not only of degree-two nodes, is required

• The set of included subtrees S(w) can be computed for each nodew ∈V (T ) in a bottom-up way

• Time complexity is dominated by the solution of a series of smallmaximum bipartite matching problems

n

∑i=1

m

∑j=1

O(outdeg(wi)outdeg(v j)1.5)

=n

∑i=1

O(m1.5outdeg(wi)) (becausem

∑j=1

outdeg(v j) = m−1)

= O(m1.5n) (becausen

∑i=1

outdeg(wi) = n−1)

Technical University of Catalonia 17/18 Gabriel Valiente

Page 63: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Solution for Unordered Trees

• A similar result was enunciated without proof in [Chung, 1987] for thesubtree homeomorphism problem but does not carry over to constrainedtree inclusion (it does not even hold for subtree homeomorphism) becausedeletion of degree-one nodes, not only of degree-two nodes, is required

• The set of included subtrees S(w) can be computed for each nodew ∈V (T ) in a bottom-up way

• Time complexity is dominated by the solution of a series of smallmaximum bipartite matching problems

n

∑i=1

m

∑j=1

O(outdeg(wi)outdeg(v j)1.5)

=n

∑i=1

O(m1.5outdeg(wi)) (becausem

∑j=1

outdeg(v j) = m−1)

= O(m1.5n) (becausen

∑i=1

outdeg(wi) = n−1)

Technical University of Catalonia 17/18 Gabriel Valiente

Page 64: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Related Work

• Constrained tree inclusion is related to the tree edit problem

• Insertions are forbidden in tree inclusion• Deletions of degree-one and degree-two nodes only are allowed in

constrained tree inclusion• Constrained tree inclusion is equivalent to degree-two tree edit

• Solvable for unordered trees in O(mnmin(deg(P),deg(T ))) time• Solvable for ordered trees in O(mn) time using O(mn) space

[Zhang, 1996; Zhang, Wang, Shasha, 1996]

• Constrained tree inclusion is easier than degree-two tree edit• For unordered trees

• Solvable in O(m√

mn) time using O(mn) space• Simple algorithm that involves the solution of a series of small

maximum bipartite matching problems• For ordered trees

• Solvable in O(mn) time using O(mn) space• Simple algorithm to find a noncrossing matching covering one of

the bipartite sets in an ordered bipartite graph

Technical University of Catalonia 18/18 Gabriel Valiente

Page 65: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Related Work

• Constrained tree inclusion is related to the tree edit problem• Insertions are forbidden in tree inclusion

• Deletions of degree-one and degree-two nodes only are allowed inconstrained tree inclusion

• Constrained tree inclusion is equivalent to degree-two tree edit• Solvable for unordered trees in O(mnmin(deg(P),deg(T ))) time• Solvable for ordered trees in O(mn) time using O(mn) space

[Zhang, 1996; Zhang, Wang, Shasha, 1996]

• Constrained tree inclusion is easier than degree-two tree edit• For unordered trees

• Solvable in O(m√

mn) time using O(mn) space• Simple algorithm that involves the solution of a series of small

maximum bipartite matching problems• For ordered trees

• Solvable in O(mn) time using O(mn) space• Simple algorithm to find a noncrossing matching covering one of

the bipartite sets in an ordered bipartite graph

Technical University of Catalonia 18/18 Gabriel Valiente

Page 66: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Related Work

• Constrained tree inclusion is related to the tree edit problem• Insertions are forbidden in tree inclusion• Deletions of degree-one and degree-two nodes only are allowed in

constrained tree inclusion

• Constrained tree inclusion is equivalent to degree-two tree edit• Solvable for unordered trees in O(mnmin(deg(P),deg(T ))) time• Solvable for ordered trees in O(mn) time using O(mn) space

[Zhang, 1996; Zhang, Wang, Shasha, 1996]

• Constrained tree inclusion is easier than degree-two tree edit• For unordered trees

• Solvable in O(m√

mn) time using O(mn) space• Simple algorithm that involves the solution of a series of small

maximum bipartite matching problems• For ordered trees

• Solvable in O(mn) time using O(mn) space• Simple algorithm to find a noncrossing matching covering one of

the bipartite sets in an ordered bipartite graph

Technical University of Catalonia 18/18 Gabriel Valiente

Page 67: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Related Work

• Constrained tree inclusion is related to the tree edit problem• Insertions are forbidden in tree inclusion• Deletions of degree-one and degree-two nodes only are allowed in

constrained tree inclusion• Constrained tree inclusion is equivalent to degree-two tree edit

• Solvable for unordered trees in O(mnmin(deg(P),deg(T ))) time• Solvable for ordered trees in O(mn) time using O(mn) space

[Zhang, 1996; Zhang, Wang, Shasha, 1996]

• Constrained tree inclusion is easier than degree-two tree edit• For unordered trees

• Solvable in O(m√

mn) time using O(mn) space• Simple algorithm that involves the solution of a series of small

maximum bipartite matching problems• For ordered trees

• Solvable in O(mn) time using O(mn) space• Simple algorithm to find a noncrossing matching covering one of

the bipartite sets in an ordered bipartite graph

Technical University of Catalonia 18/18 Gabriel Valiente

Page 68: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Related Work

• Constrained tree inclusion is related to the tree edit problem• Insertions are forbidden in tree inclusion• Deletions of degree-one and degree-two nodes only are allowed in

constrained tree inclusion• Constrained tree inclusion is equivalent to degree-two tree edit

• Solvable for unordered trees in O(mnmin(deg(P),deg(T ))) time

• Solvable for ordered trees in O(mn) time using O(mn) space[Zhang, 1996; Zhang, Wang, Shasha, 1996]

• Constrained tree inclusion is easier than degree-two tree edit• For unordered trees

• Solvable in O(m√

mn) time using O(mn) space• Simple algorithm that involves the solution of a series of small

maximum bipartite matching problems• For ordered trees

• Solvable in O(mn) time using O(mn) space• Simple algorithm to find a noncrossing matching covering one of

the bipartite sets in an ordered bipartite graph

Technical University of Catalonia 18/18 Gabriel Valiente

Page 69: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Related Work

• Constrained tree inclusion is related to the tree edit problem• Insertions are forbidden in tree inclusion• Deletions of degree-one and degree-two nodes only are allowed in

constrained tree inclusion• Constrained tree inclusion is equivalent to degree-two tree edit

• Solvable for unordered trees in O(mnmin(deg(P),deg(T ))) time• Solvable for ordered trees in O(mn) time using O(mn) space

[Zhang, 1996; Zhang, Wang, Shasha, 1996]

• Constrained tree inclusion is easier than degree-two tree edit• For unordered trees

• Solvable in O(m√

mn) time using O(mn) space• Simple algorithm that involves the solution of a series of small

maximum bipartite matching problems• For ordered trees

• Solvable in O(mn) time using O(mn) space• Simple algorithm to find a noncrossing matching covering one of

the bipartite sets in an ordered bipartite graph

Technical University of Catalonia 18/18 Gabriel Valiente

Page 70: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Related Work

• Constrained tree inclusion is related to the tree edit problem• Insertions are forbidden in tree inclusion• Deletions of degree-one and degree-two nodes only are allowed in

constrained tree inclusion• Constrained tree inclusion is equivalent to degree-two tree edit

• Solvable for unordered trees in O(mnmin(deg(P),deg(T ))) time• Solvable for ordered trees in O(mn) time using O(mn) space

[Zhang, 1996; Zhang, Wang, Shasha, 1996]

• Constrained tree inclusion is easier than degree-two tree edit

• For unordered trees• Solvable in O(m

√mn) time using O(mn) space

• Simple algorithm that involves the solution of a series of smallmaximum bipartite matching problems

• For ordered trees• Solvable in O(mn) time using O(mn) space• Simple algorithm to find a noncrossing matching covering one of

the bipartite sets in an ordered bipartite graph

Technical University of Catalonia 18/18 Gabriel Valiente

Page 71: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Related Work

• Constrained tree inclusion is related to the tree edit problem• Insertions are forbidden in tree inclusion• Deletions of degree-one and degree-two nodes only are allowed in

constrained tree inclusion• Constrained tree inclusion is equivalent to degree-two tree edit

• Solvable for unordered trees in O(mnmin(deg(P),deg(T ))) time• Solvable for ordered trees in O(mn) time using O(mn) space

[Zhang, 1996; Zhang, Wang, Shasha, 1996]

• Constrained tree inclusion is easier than degree-two tree edit• For unordered trees

• Solvable in O(m√

mn) time using O(mn) space• Simple algorithm that involves the solution of a series of small

maximum bipartite matching problems• For ordered trees

• Solvable in O(mn) time using O(mn) space• Simple algorithm to find a noncrossing matching covering one of

the bipartite sets in an ordered bipartite graph

Technical University of Catalonia 18/18 Gabriel Valiente

Page 72: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Related Work

• Constrained tree inclusion is related to the tree edit problem• Insertions are forbidden in tree inclusion• Deletions of degree-one and degree-two nodes only are allowed in

constrained tree inclusion• Constrained tree inclusion is equivalent to degree-two tree edit

• Solvable for unordered trees in O(mnmin(deg(P),deg(T ))) time• Solvable for ordered trees in O(mn) time using O(mn) space

[Zhang, 1996; Zhang, Wang, Shasha, 1996]

• Constrained tree inclusion is easier than degree-two tree edit• For unordered trees

• Solvable in O(m√

mn) time using O(mn) space

• Simple algorithm that involves the solution of a series of smallmaximum bipartite matching problems

• For ordered trees• Solvable in O(mn) time using O(mn) space• Simple algorithm to find a noncrossing matching covering one of

the bipartite sets in an ordered bipartite graph

Technical University of Catalonia 18/18 Gabriel Valiente

Page 73: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Related Work

• Constrained tree inclusion is related to the tree edit problem• Insertions are forbidden in tree inclusion• Deletions of degree-one and degree-two nodes only are allowed in

constrained tree inclusion• Constrained tree inclusion is equivalent to degree-two tree edit

• Solvable for unordered trees in O(mnmin(deg(P),deg(T ))) time• Solvable for ordered trees in O(mn) time using O(mn) space

[Zhang, 1996; Zhang, Wang, Shasha, 1996]

• Constrained tree inclusion is easier than degree-two tree edit• For unordered trees

• Solvable in O(m√

mn) time using O(mn) space• Simple algorithm that involves the solution of a series of small

maximum bipartite matching problems

• For ordered trees• Solvable in O(mn) time using O(mn) space• Simple algorithm to find a noncrossing matching covering one of

the bipartite sets in an ordered bipartite graph

Technical University of Catalonia 18/18 Gabriel Valiente

Page 74: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Related Work

• Constrained tree inclusion is related to the tree edit problem• Insertions are forbidden in tree inclusion• Deletions of degree-one and degree-two nodes only are allowed in

constrained tree inclusion• Constrained tree inclusion is equivalent to degree-two tree edit

• Solvable for unordered trees in O(mnmin(deg(P),deg(T ))) time• Solvable for ordered trees in O(mn) time using O(mn) space

[Zhang, 1996; Zhang, Wang, Shasha, 1996]

• Constrained tree inclusion is easier than degree-two tree edit• For unordered trees

• Solvable in O(m√

mn) time using O(mn) space• Simple algorithm that involves the solution of a series of small

maximum bipartite matching problems• For ordered trees

• Solvable in O(mn) time using O(mn) space• Simple algorithm to find a noncrossing matching covering one of

the bipartite sets in an ordered bipartite graph

Technical University of Catalonia 18/18 Gabriel Valiente

Page 75: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Related Work

• Constrained tree inclusion is related to the tree edit problem• Insertions are forbidden in tree inclusion• Deletions of degree-one and degree-two nodes only are allowed in

constrained tree inclusion• Constrained tree inclusion is equivalent to degree-two tree edit

• Solvable for unordered trees in O(mnmin(deg(P),deg(T ))) time• Solvable for ordered trees in O(mn) time using O(mn) space

[Zhang, 1996; Zhang, Wang, Shasha, 1996]

• Constrained tree inclusion is easier than degree-two tree edit• For unordered trees

• Solvable in O(m√

mn) time using O(mn) space• Simple algorithm that involves the solution of a series of small

maximum bipartite matching problems• For ordered trees

• Solvable in O(mn) time using O(mn) space

• Simple algorithm to find a noncrossing matching covering one ofthe bipartite sets in an ordered bipartite graph

Technical University of Catalonia 18/18 Gabriel Valiente

Page 76: Constrained Tree Inclusion 14th Annual Symposium on ...stelo/cpm/cpm03/Valiente.pdf · Constrained Tree Inclusion 14th Annual Symposium on Combinatorial Pattern Matching Gabriel Valiente

Related Work

• Constrained tree inclusion is related to the tree edit problem• Insertions are forbidden in tree inclusion• Deletions of degree-one and degree-two nodes only are allowed in

constrained tree inclusion• Constrained tree inclusion is equivalent to degree-two tree edit

• Solvable for unordered trees in O(mnmin(deg(P),deg(T ))) time• Solvable for ordered trees in O(mn) time using O(mn) space

[Zhang, 1996; Zhang, Wang, Shasha, 1996]

• Constrained tree inclusion is easier than degree-two tree edit• For unordered trees

• Solvable in O(m√

mn) time using O(mn) space• Simple algorithm that involves the solution of a series of small

maximum bipartite matching problems• For ordered trees

• Solvable in O(mn) time using O(mn) space• Simple algorithm to find a noncrossing matching covering one of

the bipartite sets in an ordered bipartite graph

Technical University of Catalonia 18/18 Gabriel Valiente