Transcript
Page 1: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Trees and Distance

Page 2: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree 1 Spanning subgraph of G : a subgraph with v

ertex set V(G) Spanning tree : a spanning subgraph that is

a tree Star : a tree consisting of one vertex adjace

nt to all the others.

Page 3: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Properties of trees Lemma : every tree with at least two vertices has at

least two leaves. Deleting a leaf from an n-vertex tree produces a tree with n-1 vertices.

Theorem : (A) G is connected and has no cycles(B) G is connected and has n-1 edges(C) G has n-1 edges and no cycles(D) For u,v V(G), G has exactly one u,v-path

Page 4: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Proof theorem A -> B,C : by induction on n. B-> A,C : delete edges from cycles of G one b

y one…. C -> A,B : let G has k components. e(Gi) = n(G

i)-1 . e(G)=i[n(Gi)-1]=n-k…. A->D : if some pair of vertices is connected b

y more than one path, it will form a cycle. D->A : if G has a cycle, then G has more than

one u,v – path .

Page 5: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Properties of trees Corollary : (a) every edge of a tree is a cut edge. (b) adding

one edge to a tree forms exactly one cycle. (c) every connected graph contains a spanning tree.

Proposition : if T,T’ are spanning trees of G and e E(T)-E(T’), then there is an edge e’ E(T’)-E(T) such that T-e+e’ is a spanning tree of G.

Page 6: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Properties of trees Proposition : if T is a tree with k edges and

G is a simple graph with (G)k, then T is a subgraph of G.

Page 7: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Distance in trees and graphs

d(u,v) : is the least length of a u,v-path Diameter : max u,vV(G) d(u,v) Eccentricity of a vertex u, (u) : max u,v

V(G) d(u,v) Radius of G : is min uV(G) (u)

Page 8: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Distance in trees and graphs Theorem : if G is a simple graph, then dia

mG3 -> diamĜ3 Proof : u,v have no common neighbor. x

V(G)-{u,v} has at least one of {u,v} as a nonneighbor. This makes x adjacent in to Ĝat least one of {u,v}. uvE( )….Ĝ

Page 9: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Distance in trees and graphs Center of G : the subgraph induced by the vertic

es of minimum eccentricity. Theorem : the center of a tree is a vertex or an e

dge.

Page 10: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Wiener index

Wiener index of G : D(G) = u,vV(G)dG(u,v) Theorem : among trees with n vertices, the

Wiener index D(T) is minimized by stars and maximized by paths ,both uniquely.

Page 11: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

2.2 spanning trees and enumeration

Prüfer code : 12 34

56

7

8

{7}

{7,4}

{7,4,4}

{7,4,4,1}

{7,4,4,1,7}

{7,4,4,1,7,1}

Page 12: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Prüfer code

12 34

56

7

8

{7,4,4,1,7,1}

{4,4,1,7,1}

{4,1,7,1}

{1,7,1}

{7,1}

{1}

Page 13: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

enumeration

Corollary : given positive integers d1,…, dn summing to 2n-2, there are exactly (n-2)!/(di-1)! Trees with vertex set [n] such that vertex i has degree di, for each i.

Page 14: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Spanning trees in graphs Proposition : Let (G) denote the number of spanni

ng trees of a graph G. If eE(G) is not a loop, then (G)=(G-e)+(G‧e)

Page 15: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Matrix tree theorem

Page 16: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Decomposition and graceful labelings A graceful labeling of a graph G with m edges is a fu

nction f:V(G)->{0,…,m} such that distinct vertices receive distinct numbers and {|f(u)-f(v)|:uvE(G} ={1,…,m}.

Conjecture : every tree has a graceful labeling. Theorem : if a tree T with m edges has a graceful la

beling, then K2m+1 has a decomposition into 2m+1 copies of T.

Page 17: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

caterpillar Caterpillar : a tree in which a single path is

incident to (or contains) every edge.

Theorem : A tree is a caterpillar iff it does not contain the tree Y above.

Y

Page 18: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Branchings and eulerian digraphs Branching(out-tree) : an orientation of a tree havin

g a root of indegree 0 and all other vertices of indegree 1.

Theorem : directed matrix tree theorem : the number of spanning out-trees of G rooted at vi is the value of each cofactor in the ith row of Q- (Q- =D--A’).

0 0 0

Q- = -1 1 0

-1 -1 2

0 0 0

A’ = 1 0 0

1 1 0

0 0 0

D- = 0 1 0

0 0 2

Page 19: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Eulerian circuit in directed graph Lemma : in a strong digraph, every vertex is the roo

t of an out-tree. Eulerian circuit in directed graph algorithm :

Page 20: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

2.3 Optimization and Trees

Theorem : in a Eulerian digraph with di=d+(vi)=d-(vi) the number of Eulerian circuits is ci(di-1)!, where c counts the in-trees to or out-trees from any vertex.

Weighted graph : a graph with numerical labels on the edges

Page 21: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Minimum spanning tree

Kruskal’s Algorithm :

1 8

7

11

10

12

5 3

6

9

2 4

Page 22: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Shortest paths Distance d(u,z) in a weighted graph is the minimu

m sum of the weights on the edges in a u,z-path. Dijkstra’s algorithm :

1 4

3

4

5

e

6

5 d

2

u

a

cb

1

3

5

6

8{u,a}

a

b

c

d

e

s

1

3

1

3

5

6

1

3

5

6

1

3

5

6

8{u,a,b,c,d}

{u,a,b}

{u,a,b,c}

{u,a,b,c,d,e}

Page 23: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Chinese Postman Problem

BFS algorithm Chinese Postman Problem

1

1

1 1

1

1

2

2

2

2

3

3 3

3

4

4 4

4

7

7

Page 24: Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree

Trees in computer science

Binary tree : a rooted tree where each vertex has at most two children.

K-ary tree allows each vertex up to k children.

Prefix-code Huffman’s algorithm


Recommended