Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
ioc.pdf
TREES
Schaum's outline Chapter 8
Rosen Chapter 11
November 21, 2019
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 1 / 60
ioc.pdf
Contents
1 De�nition and properties
2 Spanning trees of a graph
3 Counting of trees
Counting of labelled trees
Counting of unlabelled trees
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 2 / 60
ioc.pdf
Next section
1 De�nition and properties
2 Spanning trees of a graph
3 Counting of trees
Counting of labelled trees
Counting of unlabelled trees
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 3 / 60
ioc.pdf
Tree and forestA graph is called acyclic if it does not have any cycle.
De�nitionAn acyclic graph is called forest. A connected forest is a tree.
Examples of trees
A vertex of degree one is called a leaf.
Every non-trivial tree has a leaf.
PropositionEvery tree (or forest) is bipartite.
Proof. All cycles of a tree (a forest) have even length (namely, zero), so it is bipartite.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 4 / 60
ioc.pdf
Tree and forestA graph is called acyclic if it does not have any cycle.
De�nitionAn acyclic graph is called forest. A connected forest is a tree.
Examples of trees
A vertex of degree one is called a leaf.
Every non-trivial tree has a leaf.
PropositionEvery tree (or forest) is bipartite.
Proof. All cycles of a tree (a forest) have even length (namely, zero), so it is bipartite.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 4 / 60
ioc.pdf
Edges and connected components
LemmaLet a graph G has n vertices, m edges and k connected components. Then n−k 6m.
Proof. Induction on m.
Base case. If m= 0, Then G then every single vertex is a connectedcomponent, i.e. k = n and the proposition is true.
Step. Let m > 0. Delete an edge e and consider the graph G −e. This graphhas m−1 edges. There are two cases:
The number of connected components of G −e is same as of G . Then,induction hypothesis implies n−k 6m−1<m.The number of connected components of G −e is greater by one than ofG . Then we get n− (k+1)6m−1. Hence, n−k 6m.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 5 / 60
ioc.pdf
Connectedness and acyclicity
TheoremLet a graph T = (V ,E) has n vertices. Every proposition below follows from the others:
(a) T is connected;
(b) T acyclic;
(c) Thas n−1 edges.
Proof.
(a) & (b)⇒(c). Induction on n. If T contains one vertex, then all edges are loops and T has acycle that is contradicting to the premise (b). Thus, the number of edges have to be 0.
If n > 0, then (a) implies that for every node, there is at least one edge incident with it, and (b)implies that there exists a vertex v of defree deg(v)< 2 (otherwise, T would contain a cycle).
The subgraph T ′ induced by the set of vertices V \{v} is connected and acyclic. Inductionhypothesis yield that T ′ has n−2 edges.
The graph T has one edge more than T ′.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 6 / 60
ioc.pdf
Connectedness and acyclicity (continuation of the proof ...)
(b) & (c)⇒(a). By contradiction. Assume that T is not connected, i.e. it has k connectedcomponents T1, . . . ,Tk ,that all are connected and acyclic. Then, due to the previous case, everysuch component has one edge less than the number of vertices. This means that T has in totaln−k edges. The premise (c) asserts that the graph has n−1 edges, k = 1 i.e. T is connected.
(a) & (c)⇒(b). Let's assume that T has a cycle. Removing an edge from this cycle, the graphis still connected and has n vertices and n−2 edges, that is contradicting to the Lemma above.
Two alternative de�nitions for treeA connected graph with n vertices and n−1 edges is a tree.
An acyclic graph with n vertices and n−1 edges is a tree.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 7 / 60
ioc.pdf
Connectedness and acyclicity (continuation of the proof ...)
(b) & (c)⇒(a). By contradiction. Assume that T is not connected, i.e. it has k connectedcomponents T1, . . . ,Tk ,that all are connected and acyclic. Then, due to the previous case, everysuch component has one edge less than the number of vertices. This means that T has in totaln−k edges. The premise (c) asserts that the graph has n−1 edges, k = 1 i.e. T is connected.
(a) & (c)⇒(b). Let's assume that T has a cycle. Removing an edge from this cycle, the graphis still connected and has n vertices and n−2 edges, that is contradicting to the Lemma above.
Two alternative de�nitions for treeA connected graph with n vertices and n−1 edges is a tree.
An acyclic graph with n vertices and n−1 edges is a tree.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 7 / 60
ioc.pdf
Connectedness of trees
De�nitsioonA bridge (or cut-edge) is an edge of a graph whose deletion increases its number of connectedcomponents.
TheoremA graph T a tree i� it is connected and every edge of T is a bridge.
Proof.
Necessity. Let a tree T has n vertices and n−1 edges. After removing one edge, the remaininggraph with n−2 edges cannot be any more connected (due to Lemma above). Thus, theremobved edge was a bridge.
Su�ciency. All edges that belong to a cycle cannot be bridges, as removing a such an edge doesnot change the graph unconnected. So, if T is connected and its every edge is a bridge, then Tis acyclic, and hence, it is a tree.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 8 / 60
ioc.pdf
Some important properties of trees
TheoremLet T be a graph with n vertices. The following propositions are equivalent:
(a) T is a tree;
(b) there is a unique simple path between any two vertices of T ;
(c) T contains no cycles, but adding any new edge creates a cycle.
Proof.
(a) ⇒(b). From connectedness of a tree it follows that there is a simple path between every twovertices. If there is more than one such path, they would form a cycle and the graph is not atree.
(b) ⇒(c). T contains no cycles because two vertices of a cycle wolud be connected by at leasttwo di�erent simple paths. But adding anew edge e between u and v led to the cycleu v e−− u.
(c) ⇒(a). Suppose that T is not connected. Addin an edge between vertices of two connectedcomponents do not form any cycle. This is contradicting (c). So, T is a tree.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 9 / 60
ioc.pdf
Rooted tree
De�nitionA rooted tree is a tree in which one vertex is distinguished from the others and is called the root.
The level of a vertex is the number of edges along the unique path between it and theroot.
The height of a rooted tree is the maximum level to any vertex of the tree.
The children of a vertex v are those vertices that are adjacent to v and one level fartheraway from the root than v .
When every vertex in a rooted tree has at most two children, the tree is called a binarytree.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 10 / 60
ioc.pdf
Rooted tree
De�nitionA rooted tree is a tree in which one vertex is distinguished from the others and is called the root.
The level of a vertex is the number of edges along the unique path between it and theroot.
The height of a rooted tree is the maximum level to any vertex of the tree.
The children of a vertex v are those vertices that are adjacent to v and one level fartheraway from the root than v .
When every vertex in a rooted tree has at most two children, the tree is called a binarytree.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 10 / 60
ioc.pdf
Next section
1 De�nition and properties
2 Spanning trees of a graph
3 Counting of trees
Counting of labelled trees
Counting of unlabelled trees
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 11 / 60
ioc.pdf
Spanning tree
De�nition
Let G be a simple graph. A spanning tree of G is a subgraph of G that is a
tree containing every vertex of G .
Examples of spanning trees
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 12 / 60
ioc.pdf
Minimum Spanning Tree Problem
Given weighted graph G = (V ,E ,w), �nd a minimum-cost spanning tree for V .
Algorithm by Joseph Kruskal)
Input: A weighted graph G = (V ,E ,w), where |V |= n.
Output: Weighted tree T = (V ,E ′,w) where E ′ ⊆ E , such that for any other weightedtree T ′ = (V ,E ′′,w) whith E ′′ ⊆ E , such that for any other weighted tree thefollowing is true:
w(T ) = ∑e∈E ′
w(e)6 ∑e∈E ′′
w(e) = w(T ′)
1 Sort all the edges in non-decreasing order of their weight.
2 Pick the smallest edge. Check if it forms a cycle with the spanning treeformed so far. If cycle is not formed, include this edge. Else, discard it.
3 Repeat step #2 until there are n−1 edges in the spanning tree.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 13 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Example: �nding a minimal spanning tree
96155
152
59
111
101
12991
48
84
93
64
99 72108
97
91143
99
8478
72
7951
103
73
87
71
12868
48
25
68
113
136
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 14 / 60
ioc.pdf
Next section
1 De�nition and properties
2 Spanning trees of a graph
3 Counting of trees
Counting of labelled trees
Counting of unlabelled trees
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 15 / 60
ioc.pdf
Next subsection
1 De�nition and properties
2 Spanning trees of a graph
3 Counting of trees
Counting of labelled trees
Counting of unlabelled trees
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 16 / 60
ioc.pdf
Labelled treesWhen do we consider two trees di�erent (= not isomorphic)? � There are more than onereasonable answers to this question.
Are these trees the same?
YES, if we do not distinguish isomorphic trees from each other:
NO, if we give names (numbers) to the nodes:
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 17 / 60
ioc.pdf
Labelled graph
De�nitionLet M ⊆ N is a �nite set of labels. A labelled graph is a triple GM = (V ,E ,µ), where
G = (V ,E) is a graph
µ : V →M is a bijective mapping.
Example: the labelled graph with the set of labels {2,4,5,6}
5
2 4
6
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 18 / 60
ioc.pdf
Isomorphism of labelled graphs
Labelled graphs GM = (V1,E1,µ1) and HM = (V2,E2,µ2) are isomorphic (notation GM∼=HM), if
there is such a mapping ϕ : V1→ V2 that
ϕ is an isomorphism between G = (V1,E1) and H = (V2,E2);
µ1(v) = µ2(ϕ(v)) for every vertex v ∈ V1.
Example: non-isomorphic trees with three vertices
1 2 3 2 1 3 1 3 2
How many labelled trees (with the set of labels {1,2,3,4}) exist?
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 19 / 60
ioc.pdf
How to store a tree?
A. Adjacency matrix
Example (a general method for any graph)
1
2
3
4
A=
0 1 1 0
1 0 1 1
1 1 0 0
0 1 0 0
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 20 / 60
ioc.pdf
How to store a tree?
B. A list of edges
Example
3 10 2 6
4
97 8
5
1
(7 8 9 6 3 10 2 6 69 9 2 2 10 2 4 1 5
)The amount of memory needed:
2(n−1)dlog2 ne (for the list of edges)
(n2−n)/2 (for the adjacency matrix)
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 21 / 60
ioc.pdf
How to store a tree?
C. The father code:
Example
3 10 2 6
4
97 8
5
1
(1 2 3 4 5 6 7 8 96 10 10 2 6 2 9 9 2
)or simply(
6 10 10 2 6 2 9 9 2)
The amount of memory needed: (n−1)dlog2 ne
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 22 / 60
ioc.pdf
How to store a tree?D. Prüfer code
1 Write down (similarly to what was done for the father code) the edge that is incident tonode with the smallest label and delete the edge;
2 Repeat the '#1 until there are edges left in the graph;
3 Delete the �rst row (the second row is the Prüfer code;
4 Delete the last element of the sequence (as this is always the largest label).
Example
3 10 2 6
4
97 8
5
1
Intermediate result or Extended Prüfer code:(1 3 4 5 6 7 8 9 26 10 2 6 2 9 9 2 10
)
The Prüfer code of the tree:(6 10 2 6 2 9 9 2
)Memory needed: (n−2)dlog2 ne [email protected] Logic and Discrete Mathematics: Trees November 21, 2019 23 / 60
ioc.pdf
Construction of a Prüfer code
For any tree T labelled with the numbers 1,2, . . . ,n , we can form a Prüfer codeP = [p1,p2, . . . ,pn−2] of length n−2 as follows:
1 P := [ ];
2 Repeat until only two vertices remain
(a) Let ` be the leaf in the tree with the smallest number, and let m be the label of thevertex adjacent to it (there is only oen such vertex!). Append m to P (notationP := P ·m);
(b) Delete vertex ` from the tree T ;
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 24 / 60
ioc.pdf
Example: generation of Prüfer code (1) c©Peeter Laud
6
8
2
11
10
9
1
3
7 4
5
Code:
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 25 / 60
ioc.pdf
Example: generation of Prüfer code (2) c©Peeter Laud
6
8
2
11
10
9
1
3
7 4
5
Code:
9
1
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 26 / 60
ioc.pdf
Example: generation of Prüfer code (3) c©Peeter Laud
6
8
2
11
10
9
1
3
7 4
5
Code: 9
1
3
4
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 27 / 60
ioc.pdf
Example: generation of Prüfer code (4) c©Peeter Laud
6
8
2
11
10
9
1
3
7 4
5
Code: 93
1 4
3
5
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 28 / 60
ioc.pdf
Example: generation of Prüfer code c©Peeter Laud
6
8
2
11
10
9
1
3
7 4
5
Code: 933
5
1 4
26
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 29 / 60
ioc.pdf
Example: generation of Prüfer code (6) c©Peeter Laud
6
8
2
11
10
9
1
3
7 4
5
Code: 9332
65
1 4
3
7
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 30 / 60
ioc.pdf
Example: generation of Prüfer code (7) c©Peeter Laud
6
8
2
11
10
9
1
3
7 4
5
Code: 93323
7
65
1 4
9 3
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 31 / 60
ioc.pdf
Example: generation of Prüfer code (8) c©Peeter Laud
6
8
2
11
10
9
1
3
7 4
5
Code: 933239
3
7
65
1 4
2
8
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 32 / 60
ioc.pdf
Example: generation of Prüfer code c©Peeter Laud
6
8
2
11
10
9
1
3
7 4
5
Code: 9332392
8
3
7
65
1 4
9
10
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 33 / 60
ioc.pdf
Example: generation of Prüfer code (10) c©Peeter Laud
6
8
2
11
10
9
1
3
7 4
5
Code: 93323929
10
8
3
7
65
1 4
2
9
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 34 / 60
ioc.pdf
Example: generation of Prüfer code (11) c©Peeter Laud
6
8
2
11
10
9
1
3
7 4
5
Code: 933239292
9
10
8
3
7
65
1 4
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 35 / 60
ioc.pdf
Example: generation of Prüfer code (the result) c©Peeter Laud
6
8
2
11
10
9
1
3
7 4
5
Code: 933239292
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 36 / 60
ioc.pdf
Prufer codes de�ne unique trees
We will show that any (n−2)�length sequence of numbers from the set {1,2, . . . ,n} de�nes aunique labelled tree T with n vertices by reversing the above process.
Note thatLeaves, vertices of degree 1, will never appear in the sequence. (More generally, any nodev apperas in the Prüfer code deg(v)−1 times).
The �rst number in the code is the neighbour of the smallest numbered leaf.
The smallest numbered leaf has the smallest number which doesn't appear in thesequence.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 37 / 60
ioc.pdf
Reversing the Prüfer codeLet's have
M = {1,2, . . . ,n} � a set of labels;
M = [m1,m2, . . . ,mn−2] � a sequence of labels
Our goal is
To construct the labelled tree T , which Prüfer code is P(T ) = M
Algorithm for decoding1 Generate the list of labels L= [`1, `2, . . . , `n−2] by the rule
� For every i ∈ {1, . . . ,n−2}, take `i as the least label from the set M \{l1, . . . , li−1}that does not appear in {mi , . . . ,mn−2}.
Note, that the list (`1 `2 . . . `n−2m1 m2 . . . mn−2
)is the extended Prüfer code of the tree to be composed.
2 Create the tree with two nodes` mn−2
,where ` is the element of M that does notappear in M .
3 For i = n−2,n−3, . . . ,n:� Add to the tree a new vertex with the lalbel li -ga.� Connect vertices with the labels li and mi by an edge.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 38 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code
M = {1,2, . . . ,10},code
(7 7 7 4 5 7 4 4
)
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 39 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code (2)
M = {1,2, . . . ,10},The smallest number: 1
Code: 7 7 7 4 5 7 4 4
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 40 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code (3)
M = {1,2, . . . ,10},The smallest number: 1 2
Code: 7 7 7 4 5 7 4 4
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 41 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code (4)
M = {1,2, . . . ,10},The smallest number: 1 2 3
Code: 7 7 7 4 5 7 4 4
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 42 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code (5)
M = {1,2, . . . ,10},The smallest number: 1 2 3 6
Code: 7 7 7 4 5 7 4 4
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 43 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code (6)
M = {1,2, . . . ,10},The smallest number: 1 2 3 6 8
Code: 7 7 7 4 5 7 4 4
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 44 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code (7)
M = {1,2, . . . ,10},The smallest number: 1 2 3 6 8 5
Code: 7 7 7 4 5 7 4 4
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 45 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code (8)
M = {1,2, . . . ,10},The smallest number: 1 2 3 6 8 5 7
Code: 7 7 7 4 5 7 4 4
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 46 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code (9)
M = {1,2, . . . ,10},The smallest number: 1 2 3 6 8 5 7 9
Code: 7 7 7 4 5 7 4 4
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 47 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code(10)
M = {1,2, . . . ,10},The smallest number: 1 2 3 6 8 5 7 9
Code: 7 7 7 4 5 7 4 4
104
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 48 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code(11)
M = {1,2, . . . ,10},The smallest number: 1 2 3 6 8 5 7 9
Code: 7 7 7 4 5 7 4 4
104
9
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 49 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code(12)
M = {1,2, . . . ,10},The smallest number: 1 2 3 6 8 5 7 9
Code: 7 7 7 4 5 7 4 4
104
9
7
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 50 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code(13)
M = {1,2, . . . ,10},The smallest number: 1 2 3 6 8 5 7 9
Code: 7 7 7 4 5 7 4 4
104
9
75
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 51 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code(14)
M = {1,2, . . . ,10},The smallest number: 1 2 3 6 8 5 7 9
Code: 7 7 7 4 5 7 4 4
104
9
758
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 52 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code(15)
M = {1,2, . . . ,10},The smallest number: 1 2 3 6 8 5 7 9
Code: 7 7 7 4 5 7 4 4
104
9
758
6
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 53 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code(16)
M = {1,2, . . . ,10},The smallest number: 1 2 3 6 8 5 7 9
Code: 7 7 7 4 5 7 4 4
104
9
758
6
3
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 54 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code(17)
M = {1,2, . . . ,10},The smallest number: 1 2 3 6 8 5 7 9
Code: 7 7 7 4 5 7 4 4
104
9
758
6
3
2
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 55 / 60
ioc.pdf
Example: generating the tree from the given Prüfer code(18)
M = {1,2, . . . ,10},The smallest number: 1 2 3 6 8 5 7 9
Code: 7 7 7 4 5 7 4 4
104
9
758
6
3
21
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 56 / 60
ioc.pdf
Conting of labelled trees
Theorem (Arthur Cayley)
The number of labelled trees on n nodes is nn−2.
Proof.Follows directly from the fact that there are nn−2 di�erent Prüfer codes with the lengthn−2..
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 57 / 60
ioc.pdf
Next subsection
1 De�nition and properties
2 Spanning trees of a graph
3 Counting of trees
Counting of labelled trees
Counting of unlabelled trees
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 58 / 60
ioc.pdf
Number of unlabelled trees
TheoremThe number Tn of unlabelled trees with n nodes satis�es
nn−2
n!6 Tn 6 4n−1
The lower bound follows from the fact, that any every unlabelled n-tree can be labelled inn! ways;
Every unlabelled tree is uniquely determined by its planar code. The uppper bound can bederived from the number of possible planar codes.
The planar code of the (rooted) tree is the binary string 1111100100011011010000.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 59 / 60
ioc.pdf
Number of unlabelled trees
TheoremThe number Tn of unlabelled trees with n nodes satis�es
nn−2
n!6 Tn 6 4n−1
The lower bound follows from the fact, that any every unlabelled n-tree can be labelled inn! ways;
Every unlabelled tree is uniquely determined by its planar code. The uppper bound can bederived from the number of possible planar codes.
The planar code of the (rooted) tree is the binary string 1111100100011011010000.
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 59 / 60
ioc.pdf
Number of unlabelled trees
Considering, that if n > 30, then nn−2 is greater then n!2n. Thus, the lower bound can begiven in the form that is simpler to remember. Similarly, using 4n instead of 4n−1 (thesebounds does not matter much anyway!), we get, at least for n > 30, the following boundsthat are easier to remember:
2n 6 Tn 6 4n
[email protected] Logic and Discrete Mathematics: Trees November 21, 2019 60 / 60