MorphoGraphs and Imagery

Trees
Jean Cousty
MorphoGraphs and Imagery
2011
J. Cousty : MorphoGraphs and Imagery
1/19
Outline of the lecture
1 Trees and arborescences
2 Examples of application
3 Exercises
J. Cousty : MorphoGraphs and Imagery
2/19
Trees and arborescences
Preliminary remark
In the sequel, the symbol G denotes an asymmetric graph (E , Γ)
J. Cousty : MorphoGraphs and Imagery
3/19
Trees and arborescences
Isthmus
Définition
→
−
Let u ∈ Γ
The arc u is an isthmus for G if the number of connected
→
−
components of (E , Γ \ {u}) is greater than the one of G
J. Cousty : MorphoGraphs and Imagery
4/19
Trees and arborescences
Isthmus
Définition
→
−
Let u ∈ Γ
The arc u is an isthmus for G if the number of connected
→
−
components of (E , Γ \ {u}) is greater than the one of G
Exemple
F
11
00
00
11
D
11
00
C
00
11
A
00
11
1
0
11
00
00
11
E
11
00
00
11
B
11
00
00
11
G
Exercise. Give all isthmus of this graph
J. Cousty : MorphoGraphs and Imagery
4/19
Trees and arborescences
Isthmus and cycles
Propriété
The arc u is an isthmus for G if and only if the arc u does not
appear in any cycle of G
J. Cousty : MorphoGraphs and Imagery
5/19
Trees and arborescences
Isthmus and cycles
Propriété
The arc u is an isthmus for G if and only if the arc u does not
appear in any cycle of G
Propriété
→
−
Let n = |E | and m = | Γ |
If G is connected, then m ≥ n − 1
J. Cousty : MorphoGraphs and Imagery
5/19
Trees and arborescences
Isthmus and cycles
Propriété
The arc u is an isthmus for G if and only if the arc u does not
appear in any cycle of G
Propriété
→
−
Let n = |E | and m = | Γ |
If G is connected, then m ≥ n − 1
If G has no cycle, then m ≤ n − 1
J. Cousty : MorphoGraphs and Imagery
5/19
Trees and arborescences
Tree
Définition
A tree is a connected graph that has no cycle
D
11
00
00
11
11
00
C
1
0
11
00
00 B
11
J. Cousty : MorphoGraphs and Imagery
11
00
00
11
11
00
C
A
11
00
00
11
A tree
D
E
1
0
A
11
00
00
11
11
00
00 B
11
A graph that is not a tree
6/19
E
Trees and arborescences
Tree
Définition
A tree is a connected graph that has no cycle
D
11
00
00
11
11
00
C
1
0
D
E
C
A
11
00
00
11
1
0
11
00
00 B
11
A tree
11
00
00
11
11
00
A
11
00
00
11
11
00
00 B
11
A graph that is not a tree
Remark. In a tree, each arc is an isthmus
J. Cousty : MorphoGraphs and Imagery
6/19
E
Trees and arborescences
Tree: characterization
Propriété
The four following statements are equivalent:
1 G is a tree
2 G is connected and m = n − 1
3 G has no cycle and m = n − 1
4 for any pair of two distinct vertices x and y in E , there exists
a unique elementary undirected path from x to y
J. Cousty : MorphoGraphs and Imagery
7/19
Trees and arborescences
Root
Définition
Let x be a vertex in E
x is a root of G if E is the transitive closure of {x} (i.e., if, for
each vertex y ∈ E , there exists a path from x to y )
J. Cousty : MorphoGraphs and Imagery
8/19
Trees and arborescences
Root
Définition
Let x be a vertex in E
x is a root of G if E is the transitive closure of {x} (i.e., if, for
each vertex y ∈ E , there exists a path from x to y )
D
11
00
00
11
11
00
C
1
0
D
E
C
A
11
00
00
11
11
00
00
11
11
00
1
0
A
11
00
00
11
11
00
00 B
11
11
00
00 B
11
Exercise. Give the roots of these graphs
J. Cousty : MorphoGraphs and Imagery
8/19
E
Trees and arborescences
Arborescence
Définition
An arborescence is a tree for which there is a root
J. Cousty : MorphoGraphs and Imagery
9/19
Trees and arborescences
Arborescence
Définition
An arborescence is a tree for which there is a root
D
11
00
00
11
11
00
C
1
0
E
D
C
A
11
00
00
11
11
00
00
11
11
00
1
0
A
11
00
00
11
11
00
00 B
11
11
00
00 B
11
An arborescence (left)
A tree that is not an arborescence (right)
J. Cousty : MorphoGraphs and Imagery
9/19
E
Trees and arborescences
Arborescence
Définition
An arborescence is a tree for which there is a root
A vertex x of an arborescence is a leaf if it has no successor
D
11
00
00
11
11
00
C
1
0
E
D
C
A
11
00
00
11
11
00
00
11
11
00
1
0
A
11
00
00
11
11
00
00 B
11
11
00
00 B
11
An arborescence (left)
A tree that is not an arborescence (right)
J. Cousty : MorphoGraphs and Imagery
9/19
E
Trees and arborescences
Properties of arborescences
Propriété
If G is an arborescence, there exists a unique vertex in E that is a
root of G
Root
J. Cousty : MorphoGraphs and Imagery
10/19
Trees and arborescences
Properties of arborescences
Propriété
If G is an arborescence, there exists a unique vertex in E that is a
root of G
An arborescence can be decomposed into levels
Level 0
Level 1
Level 2
J. Cousty : MorphoGraphs and Imagery
10/19
Examples of application
Problem 1: counterfeit coins
Let P = {p1 , . . . , p8 } be a set of 8 coins
7 coins have the same weight
1 is lighter than the others
Let us consider a balance with two states (<, ≥)
Problem. Find the lightest coin
J. Cousty : MorphoGraphs and Imagery
11/19
Examples of application
Decision arborescence: example
X={1,2,3,4,5,6,7,8}
1
0
{1,2,3,4}
{1,2}
1
0
1
0
{3,4}
01
1
0
{5,6}
{5,6,7,8}
{7,8}
1
0
01
01 0
1 0
1 0
1 0
1 0
1 0
1 01
{1}
{2}
{3}
{4}
{5}
{6}
{7}
{8}
Decision arborescence for the counterfeit coins problem
J. Cousty : MorphoGraphs and Imagery
12/19
Examples of application
Decision arborescence
Définition
Let P be a finite set (of possible solutions)
X={1,2,3,4,5,6,7,8}
1
0
{1,2,3,4}
{1,2}
1
0
1
0
{3,4}
1
0
1
0
{5,6}
{5,6,7,8}
{7,8}
1
0
1
0
1 0
0
1 0
1 0
1 0
1 0
1 0
1 0
1
{1}
J. Cousty : MorphoGraphs and Imagery
{2}
{3}
{4}
{5}
{6}
{7}
{8}
13/19
Examples of application
Decision arborescence
Définition
Let P be a finite set (of possible solutions)
A decision arborescence for P is a pair (G , f ) such that
G = (E , Γ) is an arborescence of root r
f is a map from E into P(P) that satisfies
f (r ) = P
∀x ∈ E | Γ(x) 6= ∅, f (x) = ∪{f (y ) | y ∈ Γ(x)}
∀x ∈ E | Γ(x) 6= ∅, |f (x)| = 1
X={1,2,3,4,5,6,7,8}
1
0
{1,2,3,4}
{1,2}
1
0
1
0
{3,4}
1
0
1
0
{5,6}
{5,6,7,8}
{7,8}
1
0
1
0
1 0
0
1 0
1 0
1 0
1 0
1 0
1 0
1
{1}
J. Cousty : MorphoGraphs and Imagery
{2}
{3}
{4}
{5}
{6}
{7}
{8}
13/19
Examples of application
Problem 2: counterfeit coins with a three states balance
Same as 1 but the considered balance has 3 states (<, =, >)
(instead of 2)
Exercise.
Give a decision arborescence for this problem
Give the number of necessary weighing to find the counterfeit
coin?
J. Cousty : MorphoGraphs and Imagery
14/19
Examples of application
Arithmetic expression evaluation
(A) =
ae x −b(y +1)
2
/
−
*
a
*
exp
x
J. Cousty : MorphoGraphs and Imagery
2
b
+
y
1
15/19
Examples of application
Ordered arborescence
Définition
An ordered graph on E is a pair (E , Γ̊) such that
Γ̊ is a map from E into the set of (ordered) sequence of elements
in E
J. Cousty : MorphoGraphs and Imagery
16/19
Examples of application
Ordered arborescence
Définition
An ordered graph on E is a pair (E , Γ̊) such that
Γ̊ is a map from E into the set of (ordered) sequence of elements
in E
Thus, Γ̊(x) = (y0 , . . . , y` ) for a given value `
J. Cousty : MorphoGraphs and Imagery
16/19
Examples of application
Ordered arborescence
Définition
An ordered graph on E is a pair (E , Γ̊) such that
Γ̊ is a map from E into the set of (ordered) sequence of elements
in E
Thus, Γ̊(x) = (y0 , . . . , y` ) for a given value `
Any ordered graph (E , Γ̊) induces a graph (E , Γ)
J. Cousty : MorphoGraphs and Imagery
16/19
Examples of application
Ordered arborescence
Définition
An ordered graph on E is a pair (E , Γ̊) such that
Γ̊ is a map from E into the set of (ordered) sequence of elements
in E
Thus, Γ̊(x) = (y0 , . . . , y` ) for a given value `
Any ordered graph (E , Γ̊) induces a graph (E , Γ)
(E , Γ̊) is an ordered arborescence if the graph (E , Γ) induced
by (E , Γ̊) is an arborescence
J. Cousty : MorphoGraphs and Imagery
16/19
Examples of application
A search arborescence
J. Cousty : MorphoGraphs and Imagery
17/19
Examples of application
A search arborescence
Let V be a set totally ordered by the relation ≤
Let X ⊆ V
J. Cousty : MorphoGraphs and Imagery
17/19
Examples of application
A search arborescence
Let V be a set totally ordered by the relation ≤
Let X ⊆ V
A search arborescence on X is an ordered arborescence (X , Γ̊)
such that
∀x ∈ X , 0 ≤ |Γ(x)| ≤ 2
∀x ∈ X | Γ̊(x) = (x1 , x2 ), any element in the sub-arborescence
rooted in x1 is smaller than x and any element in the
sub-arborescence rooted in x2 is greater than x
J. Cousty : MorphoGraphs and Imagery
17/19
Examples of application
Example
12
8
6
15
9
13
17
Search arborescence for the relation ≤ defined on V = N, with
X = {6, 8, 9, 12, 15, 13, 17}.
J. Cousty : MorphoGraphs and Imagery
18/19
Exercises
Exercises
Write an algorithm that tests if a given value ν belongs to a
search arborescence (X , Γ̊)
Write an algorithm that prints the value of an arborescence (X , Γ̊)
in increasing order
J. Cousty : MorphoGraphs and Imagery
19/19