Trees Thm 2.1. (Cayley 1889) There are nn-2 different labeled trees

Slides:



Advertisements
Similar presentations
10.4 Spanning Trees. Def Def: 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 See handout.
Advertisements

CS 473Lecture 141 CS473-Algorithms I Lecture 14-A Graph Searching: Breadth-First Search.
ALGORITHMS THIRD YEAR BANHA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATIC Lecture eight Dr. Hamdy M. Mousa.
3.3 Spanning Trees Tucker, Applied Combinatorics, Section 3.3, by Patti Bodkin and Tamsen Hunter.
Graph Traversals Visit vertices of a graph G to determine some property: Is G connected? Is there a path from vertex a to vertex b? Does G have a cycle?
Graph Searching (Graph Traversal) Algorithm Design and Analysis Week 8 Bibliography: [CLRS] – chap 22.2 –
Edited by Malak Abdullah Jordan University of Science and Technology Data Structures Using C++ 2E Chapter 12 Graphs.
CMPS 2433 Discrete Structures Chapter 5 - Trees R. HALVERSON – MIDWESTERN STATE UNIVERSITY.
Tirgul 8 Graph algorithms: Strongly connected components.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Discussion #36 Spanning Trees
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
Lecture 14: Graph Algorithms Shang-Hua Teng. Undirected Graphs A graph G = (V, E) –V: vertices –E : edges, unordered pairs of vertices from V  V –(u,v)
Tirgul 11 BFS,DFS review Properties Use. Breadth-First-Search(BFS) The BFS algorithm executes a breadth search over the graph. The search starts at a.
Minimal Spanning Trees. Spanning Tree Assume you have an undirected graph G = (V,E) Spanning tree of graph G is tree T = (V,E T E, R) –Tree has same set.
Graph Theory TreesAlgorithms. Graphs: Basic Definitions 4 n Let n be the number of nodes (stations) and e be the number of edges (links). n A graph is.
Tirgul 7 Review of graphs Graph algorithms: – BFS (next tirgul) – DFS – Properties of DFS – Topological sort.
K-Coloring k-coloring: A k-coloring of a graph G is a labeling f: V(G)  S, where |S|=k. The labels are colors; the vertices of one color form a color.
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
Graph Algorithms Using Depth First Search Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
C o n f i d e n t i a l HOME NEXT Subject Name: Data Structure Using C Unit Title: Graphs.
Data Structures Using C++ 2E
Algorithms for Enumerating All Spanning Trees of Undirected and Weighted Graphs Presented by R 李孟哲 R 陳翰霖 R 張仕明 Sanjiv Kapoor and.
Chapter 2 Graph Algorithms.
Chapter 14 Graphs. © 2004 Pearson Addison-Wesley. All rights reserved Terminology G = {V, E} A graph G consists of two sets –A set V of vertices,
Approximating the Minimum Degree Spanning Tree to within One from the Optimal Degree R 陳建霖 R 宋彥朋 B 楊鈞羽 R 郭慶徵 R
Foundations of Discrete Mathematics
CSE, IIT KGP Euler Graphs and Digraphs. CSE, IIT KGP Euler Circuit We use the term circuit as another name for closed trail.We use the term circuit as.
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.
7.1 and 7.2: Spanning Trees. A network is a graph that is connected –The network must be a sub-graph of the original graph (its edges must come from the.
CSCI 115 Chapter 7 Trees. CSCI 115 §7.1 Trees §7.1 – Trees TREE –Let T be a relation on a set A. T is a tree if there exists a vertex v 0 in A s.t. there.
 2004 SDU Lecture 7- Minimum Spanning Tree-- Extension 1.Properties of Minimum Spanning Tree 2.Secondary Minimum Spanning Tree 3.Bottleneck.
Elementary Graph Algorithms CLRS Chapter 22. Graph A graph is a structure that consists of a set of vertices and a set of edges between pairs of vertices.
5.5.2 M inimum spanning trees  Definition 24: A minimum spanning tree in a connected weighted graph is a spanning tree that has the smallest possible.
5.5.3 Rooted tree and binary tree  Definition 25: A directed graph is a directed tree if the graph is a tree in the underlying undirected graph.  Definition.
Introduction to Graph Theory
Lecture 11 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Graphs 1 Definition 2 Terminology 3 Properties 4 Internal representation Adjacency list Adjacency matrix 5 Exploration algorithms 6 Other algorithms.
Jan Topological Order and SCC Edge classification Topological order Recognition of strongly connected components.
1 Chapter 22 Elementary Graph Algorithms. 2 Introduction G=(V, E) –V = vertex set –E = edge set Graph representation –Adjacency list –Adjacency matrix.
Unit – V Graph theory. Representation of Graphs Graph G (V, E,  ) V Set of vertices ESet of edges  Function that assigns vertices {v, w} to each edge.
Graph Theory and Applications
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 20.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
Graphs Slide credits:  K. Wayne, Princeton U.  C. E. Leiserson and E. Demaine, MIT  K. Birman, Cornell U.
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Trees Dr. Yasir Ali. A graph is called a tree if, and only if, it is circuit-free and connected. A graph is called a forest if, and only if, it is circuit-free.
Graphs Lecture 2. Graphs (1) An undirected graph is a triple (V, E, Y), where V and E are finite sets and Y:E g{X V :| X |=2}. A directed graph or digraph.
Graphs & Paths Presentation : Part II. Graph representation Given graph G = (V, E). May be either directed or undirected. Two common ways to represent.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Connectivity. Graph Scanning Algorithm Input: A graph G and some vertex s. Output: The set R of vertices reachable from s and a set T ⊆ E(G) such that.
Chapter 05 Introduction to Graph And Search Algorithms.
Data Structures and Algorithm Analysis Graph Algorithms Lecturer: Jing Liu Homepage:
CSC317 1 At the same time: Breadth-first search tree: If node v is discovered after u then edge uv is added to the tree. We say that u is a predecessor.
Discrete Structures Li Tak Sing( 李德成 ) Lectures
Trees.
Graphs – Breadth First Search
Chapter 5 : Trees.
Discrete Mathematicsq
12. Graphs and Trees 2 Summary
Advanced Algorithms Analysis and Design
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Short paths and spanning trees
CSE 421: Introduction to Algorithms
Theorem 5.13: For vT‘, l’(v)= min{l(v), l(vk)+w(vk, v)}
5.4 T-joins and Postman Problems
Elementary Graph Algorithms
Graph Theory: Euler Graphs and Digraphs
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Presentation transcript:

Trees Thm 2.1. (Cayley 1889) There are nn-2 different labeled trees on n vertices. Or it can be stated as: the complete graph Kn has nn-2spanning trees.

A spanning tree of a connected graph is a subgraph that is a tree. Every tree with at least 2 vertices has at least 2 vertices of degree 1. 6 8 4 5 7 1 2 10 3 9 Consider the sequence: 2 2 1 1 7 1 10 10.

Proof 1 (Prufer): Given a spanning tree T in Kn, let T1=T and generate a sequence of trees T1, T2,…, Tn-1 and two sequences of vertices as follows: Given Ti with n-i+1 vertices, i=1..n-1, let xi be the least indexed degree 1 vertex of Ti and delete xi and its incident edge {xi, yi} from Ti to obtain Ti+1 on n-i vertices. Thus T can be encoded as (y1,…, yn-2). Claim that the encoding is 1-1 and onto. Note that there are nn-2 such encodings. First we have yn-1 = n, since every tree has at least 2 vertices of degree 1 and n will never be the least indexed degree 1 vertex.

Second, xk,…, xn-1 and n are the vertices of Tk. Third, {xi, yi}, i = k, …, n-1, are exactly the edges of Tk in some order. v occurs among y1,…, yn-2 degT(v) -1 times. Similarly, a vertex v in Tk occurs among yk,…, yn-2 is its degree in Tk less 1. The degree-1 vertices of Tk are those elements of V not in {x1,…, xk-1 } and {yk,…, yn-1 }. This implies that xk is the least degree-1 vertex of Tk not in the above sets. x1 is the least element of V not in the encoding of T and we can uniquely determine xk from the encoding and x1,…, xk-1. □

D has 2 trees rooted at 1 and n and a number (say k) of circuits. Proof 2: Consider a mapping f from {2, 3,...,n-1} to {1, 2,…, n}. There are nn-2 such mappings f. Construct a digraph D on the vertices 1 to n by defining the edge set {(i, f(i)): i=2,..n-1}. D has 2 trees rooted at 1 and n and a number (say k) of circuits. The rightmost element in the i-th component, denoted ri, is its minimal element (and li is its left neighbor). 21 1 4 5 3 7 12 19 6 20 16 9 17 10 11 2 13 14 8 15 18

The circuits are ordered by r1< r2 < … < rk. Proof 2: The circuits are ordered by r1< r2 < … < rk. We obtain a tree by adding the edges {1, l1}, {r1, l2}, …, {rk-1, lk}, {rk, n} and deleting the edges {ri, li}. Let r0=1 and ri be the minimal number on the path from ri-1 to n. By traversing the path from 1 to n, we can recover the function f.  1 21 4 5 3 7 12 19 6 20 16 9 17 10 11 2 13 14 8 15 18

Proof 3: Recall the multinomial coefficient. Denote the number of labeled trees with n vertices and degree sequence d1,...,dn by t(n; d1,...,dn) which is 0 if any di is 0. Replace n by n-2, k by n, ri by di-1 and xi by 1.

t(n;d1,...,dn): # of spanning trees t(3; 1,2,1)=t(3; 2,1,1)=t(3;1,1,2)=1 t(4;2,1,1,1)=? t(4;3,1,1,1)= t(3;2,1,1) =1 t(4;2,2,1,1)= t(3;2,1,1) + t(3;1,2,1) 1 3 2 1 2 3 2 1 3 3 4 1 2 3 4

Proof 3:

If there are k components, then how many edges are there? A graph with no polygon (cycle) as subgraph is called a forest. Each component of a forest is a tree. A weighted graph is a graph together with a function associated a real number c(e) to each edge e, c is called the weighted function. Given a weighted connected graph G, define the cost of a spanning tree T of G as c(T)= A spanning tree may represent a network of cities where c({x, y}) is the cost of erecting a telephone line joining cities x and y.

Minimum spanning tree problem is to find a spanning tree with the smallest weight. Greedy algorithm: Input G: weighted and connected. 1. At each iteration, we have a set {e1,…, ei} of i independent edges, which has n-i components. 2. If i < n-1, let ei+1 be an edge with ends in different components and whose cost is minimum. 3. Stop when n-1 edges are chosen.

Thm 2.2. With e1,…, en-1 chosen as above, the spanning tree T0 has the property that c(T0)  c(T) for any spanning tree T. Pf: Let T has edges a1,…an-1 with the weight increasing. Claim that c(ei)  c(ai) for i=1,…, n-1. If it is false, then there is some k such that c(ek) > c(ak)  c(ak-1) …. c(a1). Since none of ak,…,a1 was chosen at the point when ek was chosen, each of them must have both ends in the same component of G{e1,…, ek-1}. The # of components of G{a1,…,ak}  the # of components of G{e1,…,ek-1}, i.e., n-k+1. It contradicts that G{a1,…ak } is a forest. 

The operation of BFS on an undirected graph 1 1 v w x y v w x y Q Q s w r 1 1 (c) r s t u (d) r s t u 1 2 1 2 1 2 2 1 2 v w x y v w x y Q r t x Q t x v 1 2 2 1 2 2 (e) r s t u (f) r s t u 1 2 3 1 2 3 2 1 2 2 1 2 3 v w x y v w x y Q x v u Q v u y 2 2 3 2 3 3

(g) r s t u (h) r s t u 1 2 3 1 2 3 2 1 2 3 2 1 2 3 v w x y v w x y Q u y y 3 3 3 (i) r s t u 1 2 3 2 1 2 3 v w x y Q

Breadth-first search: Initially, vertices are colored white. Discovered vertices are colored green. When done, discovered vertices are colored black. d[u] stores the distance from s to u. is a predecessor to u on its shortest path. Q is a first-in first-out queue.

Depth First Search: (a) (b) 1/ 1/ 2/ (c) (d) 1/ 2/ 1/ 2/ 3/ 4/ 3/ u v ancestor descendent Discovery time (a) u v (b) u v 1/ 1/ 2/ x y x y (c) (d) u v u v 1/ 2/ 1/ 2/ 3/ 4/ 3/ x y x y

(e) (f) (g) 1/ 2/ 1/ 2/ 1/ 2/ 4/ 3/ 4/5 3/ 4/5 3/6 (h) (i) (j) 1/ 2/7 u v (f) u v (g) u v 1/ 2/ 1/ 2/ 1/ 2/ B B B 4/ 3/ 4/5 3/ 4/5 3/6 x y x y x y finish time (h) (i) u v (j) u v u v 1/ 2/7 1/ 2/7 1/8 2/7 B B F B F 4/5 3/6 4/5 3/6 4/5 3/6 y x y x y

Since G is finite, inductively, we can show y is a descendent of x. Proposition 2.3. If vertices x and y are adjacent in G, then one of the them is a descendent of the other in any DFS tree T. Pf: Suppose x is discovered at time k and earlier than y in the DFS. Let u be the next discovered vertex after x. If u=y then we are done. If not then y is still waiting to be discovered. u x Since G is finite, inductively, we can show y is a descendent of x. y

Isthmus (or bridge) is an edge in a graph whose deletion results in a disconnected graph. Proposition 2.4. Let {x, y} be an edge (not isthmus) of T in G. Let x be the parent of y. Then there is an edge in G but not in T joining some descendent a of y and some ancestor b of x. b x y a Assigning a direction to each edge of an undirected graph G is called an orientation of G. A walk in a digraph may be called strong when each edge is traversed by the walk according to its direction. A digraph is strongly connected if for any two vertices x and y, there is a strong walk from x to y.

Thm 2.5. G: finite, connected, no isthmus. Then G admits a strong orientation. Pf. Goal: Construct a digraph D from G by choosing a direction for each edge. Find a DFS tree T and number the vertices from v0. Let e={vi, vj} be an edge of G with i < j. If e is in T, direct it from vi to vj , else from vj to vi. Need to show that D is strongly connected. There is a strong walk from v0 to any vertex x. It remains to show there is a strong walk from x to v0. By induction on the distance between x and v0 , and Prop 2.4. x v0