880 likes | 1.53k Views
Chapter 2. 2.1 Basic properties 2.2 Spanning tree and enumeration 2.3 Optimization and trees. Trees and Distance. Acyclic, tree 2.1.1. A graph with no cycle is acyclic A forest is an acyclic graph A tree is a connected acyclic graph
E N D
Chapter 2 2.1 Basic properties 2.2 Spanning tree and enumeration 2.3 Optimization and trees Trees and Distance Ch. 2. Trees and Distance
Acyclic, tree2.1.1 • A graph with no cycle is acyclic • A forestis an acyclic graph • A tree is a connected acyclic graph • A leaf (or pendant vertex ) is a vertex of degree 1 leaf tree tree forest Ch. 2. Trees and Distance
Spanning Subgraph 2.1.1 • A spanning subgraphof G is a subgraph with vertex setV(G) • A spanning tree is a spanning subgraph that is a tree Spanning tree Spanning subgraph Ch. 2. Trees and Distance
Maximal path Lemma.Every tree with at least two vertices has at least two leaves.2.1.3 Proof: (1/2) • A connected graph with at least two vertices has an edge. • In an acyclic graph, an endpoint of a maximal nontrivial path has no neighbor other than its neighbor on the path. • Hence the endpoints of such a path are leaves. Impossible! Cycle occurs Impossible! It is Maximal. Ch. 2. Trees and Distance
Lemma.Deleting a leaf from a n-vertex tree produces a tree with n-1 vertices.2.1.3 Proof: (2/2) • Letvbe a leaf of a tree G, and that G’=G-v. • A vertex of degree 1 belongs to no path connecting two other vertices. • Therefore, for u, w V(G’), every u, w-path inGis also in G’. • HenceG’is connected. • Since deleting a vertex cannot create a cycle, G’also is acyclic. • ThusG’is a tree with n-1 vertices. Ch. 2. Trees and Distance
G G’ v w u • Foru, wV(G’ ), every u, w-path inGis also in G’. Ch. 2. Trees and Distance
Theorem 2.1.4.For an n-vertex graphG(with n1), the following are equivalent (and characterize the trees with nvertices)2.1.4A)Gis connected and has no cyclesB) Gis connected and hasn-1 edgesC) Ghasn-1 edges and no cyclesD) Foru, vV(G), Ghas exactly one u, v-path Proof:We first demonstrate the equivalence of A, B, and C by proving that any two of {connected, acyclic,n-1 edges} together imply the third Ch. 2. Trees and Distance
A{B,C}. connected, acyclic n-1 edgesTheorem 2.1.4Continue • We use induction on n. • Forn=1, an acyclic 1-vertex graph has no edge • Forn >1, we suppose that implication holds for graphs with fewer thannvertices • Given an acyclic connected graph G, Lemma 2.1.3 provides a leaf vand states that G’=G-valso is acyclic and connected(see figure in previous proof) • Applying the induction hypothesis to G’yields e(G’)=n-2 • Since only one edge is incident to v, we have e(G)=n-1 Ch. 2. Trees and Distance
B{A, C}Connected andn-1 edges acyclicTheorem 2.1.4 continue • If Gis not acyclic, delete edges from cycles of Gone by one until the resulting graph G’ is acyclic • Since no edge of a cycle is a cut-edge(Theorem 1.2.14), G’is connected • Now the preceding paragraph implies that e(G’) = n-1 • Since we are given e(G)=n-1, no edges were deleted • ThusG’=G, and G is acyclic Ch. 2. Trees and Distance
C{A, B} n-1 edges and no cycles connectedTheorem2.1.4 continue • LetG1,…,Gk be the components of G • Since every vertex appears in one component, in(Gi)=n • SinceG has no cycles, each component satisfies property A. Thus e(Gi) = n(Gi) - 1 • Summing over i yieldse(G)=I[n(Gi)-1]= n-k • We are given e(G)=n-1,sok =1, and Gis connected Ch. 2. Trees and Distance
ADConnected and no cycles Foru, vV(G), one and only one u, v-path exists Theorem 2.1.4 • SinceGis connected, each pair of vertices is connected by a path • If some pair is connected by more than one , we choose a shortest (total length) pair P, Qof distinct paths with the same endpoints • By this extremal choice, no internal vertex of PorQcan belong to the other path • This implies that PQis a cycle, which contradicts the hypothesis A p v u q Ch. 2. Trees and Distance
DAForu, vV(G),one and only one u, v-path exists connected and no cycles Theorem 2.1.4 • If there is a u,v-path for every u,vV(G), then Gis connected • IfGhas a cycle C, then G has two u,v-paths foru,v V(G);which contradicts the hypothesis D • HenceGis acyclic (this also forbids loops). Ch. 2. Trees and Distance
Corollary: Every edge of a tree is a cut-edge 2.1.5 Proof: • A tree has no cycles • Theorem 1.2.14 implies that every edge is a cut-edge. Ch. 2. Trees and Distance
Corollary: Adding one edge to a tree forms exactly one cycle 2.1.5 Proof: • A tree has a unique path linking each pair of vertices (Theorem2.1.4D) • Joining two vertices by an edge creates exactly one cycle Ch. 2. Trees and Distance
Corollary: Every connected graph contains a spanning tree 2.1.5 Proof: • Similar to the proof of BA, C in Theorem 2.1.4 • Iteratively deleting edges from cycles in a connected graph yields a connected acyclic subgraph Ch. 2. Trees and Distance
Proposition: IfT, T’are spanning trees of a connected graph Gand eE(T)-E(T’),then there is an edge e’E(T’)- E(T) such that T-e+e’is a spanning tree of G.2.1.6 e’ e G T T’ T-e+e’ Ch. 2. Trees and Distance
Proposition:IfT, T’are spanning trees of a connected graph Gand eE(T)-E(T’),then there is an edge e’E(T’)- E(T) such that T-e+e’is a spanning tree of G. 2.1.6 Proof: • Every edge of Tis a cut-edge ofT. Let UandU’be the two components of T-e. • Since T’is connected, T’has an edge e’with endpoints in UandU’. • Now T-e+e’is connected, has n(G)-1 edges, and is a spanning tree of G. e’ e T T’ T-e+e’ Ch. 2. Trees and Distance
Distance in trees and Graphs • Assume Ghas au, v-path • Then the distance from utov, writtendG(u,v) or d(u,v), is the least length of a u,v-path. • If Ghas no such path, then d(u,v)= Ch. 2. Trees and Distance
Distance in trees and Graphs • The diameter (diamG) is maxu,vV(G)d(u,v) • Upper bound of distance between every pair • The eccentricityof a vertex u is (u) = maxvV(G) d(u,v) • Upper bound of the distance from u to the others • The radius of a graph G is radG = minuV(G) (u) • Lower bound of the eccentricity Ch. 2. Trees and Distance
Distance, Diameter, Eccentricity, and Radius a b f e c g d Distance(f,c) : 2 Distance(g,c): 2 Distance(a,c): 3 Radius: 2 Diameter: 3 Eccentricity(f):2 Eccentricity(a): 3 Ch. 2. Trees and Distance
If G is a simple graph, then diamG 3 diam 3 2.1.11 Proof:1/3 • Since diamG> 2, there exist nonadjacent vertices u, vV(G) with no common neighbor • If any pair of nonadjacent vertices has a common neighbor, the distance of every pair is less than or equal to 2 and diamG= 2 Not every pair is of this kind u v A pair (u, v)of this kind exists Ch. 2. Trees and Distance
If G is a simple graph, then diamG 3 diam 3 2.1.11 Proof:2/3 • Hence every xV( ) - {u,v} has at least one of {u,v} as a nonneighbor • Eitheruorvis not connected to x • Equivalently, this makes x adjacent to at least one of {u,v} in Everyone of these vertices has at least one of {u,v} as a nonneighbor u v Ch. 2. Trees and Distance
If G is a simple graph, then diamG 3 diam 3 2.1.11 Proof:3/3 • Sincealso u v E( ),for every pair x, y there is an x, y-path of length at most 3 in through {u,v}. Hence diam 3 u v Ch. 2. Trees and Distance
Center 2.1.12 Definition:The center of a graph Gis the subgraph induced by the vertices of minimum eccentricity. • The center of a graph is the full graph if and only if the radius and diameter are equal. Center Recall: The eccentricityof a vertex u is the upper bound of the distance from u to the others Ch. 2. Trees and Distance
The center of a tree is a vertex or an edge2.1.13 Proof:We use induction on the number of vertices in a tree T. • Basis step: n(T)≦ 2. With at most two vertices, the center is the entire tree. Ch. 2. Trees and Distance
Theorem. 2.1.13Continue • Induction step: n(T)>2. • LetT’ = T- {leaves}. By Lemma 2.1.3, T’is a tree. • Since the internal vertices on the paths between leaves of T remain, T’has at least one vertex. • Every vertex at maximum distance in Tfrom a vertex uV(T) is a leaf (otherwise, the path reaching it from ucan be extended farther). The max path from u The end must be a leaf u T = Green Pink T’= Green Ch. 2. Trees and Distance
Theorem. 2.1.13Continue • Since all the leaves have been removed and no path between two other vertices uses a leave, T’(u)= T(u)-1 for every uV(T’). • Also, the eccentricity of a leaf in Tis greater than the eccentricity of its neighbor in T. • Hence the vertices minimizing T(u) are the same as the vertices minimizing T’(u). {v| v has min (v) in T} = {v’| v’ has min (v’) in T’} T’(u)= T(u)-1 u Ch. 2. Trees and Distance
Theorem. 2.1.13Continue • It is shownTand T’have the same center. • By the induction hypothesis, the center ofT’ is a vertex or an edge. T” T T’ Ch. 2. Trees and Distance
Spanning Trees and Enumeration2.2 • There are 2c(n,2) simple graphs with vertex set [n]={1,…,n}. • since each pair may or may not form an edge. • How many of these are trees? Can either appear or disappear Max number of edges = c(n,2) Ch. 2. Trees and Distance
Enumeration of Trees 2.2 • One or two vertices, then there is only one tree. • Three vertices, three trees. • Four vertices, then four stars and 12 paths, total 16. • Five vertices, then there are 125 trees. Ch. 2. Trees and Distance
Algorithm for tree generation by using Prűfer code2.2.1 Algorithm. (Prűfer code) Production of f(T)=(a1,…,an-2) Input: A tree Twith vertex set S N Iteration: At the i th step, delete the least remaining leaf, and say thataiis the neighborof the deleted leaf 1. Delete 2 a1= 7 2. Delete 3 a2= 4 3. Delete 5 a3= 4 4. Delete 4 a4= 1 5. Delete 6 a5= 7 6. Delete 7 a6= 1 4 1 7 3 2 5 6 8 Ch. 2. Trees and Distance
Theorem: For a set SN of size n, there are nn-2trees with vertex set S 2.2.3 Proof: (sketch) • Trees with vertex set S Sn-2of lists of length n-2 • One prufer code one tree. • There arenn-2codes. • Proved by induction Ch. 2. Trees and Distance
Spanning Trees in Graphs 2.2.6 Example. A kite. To count the spanning trees: • Four are path around the outside cycle in the drawing • The remaining spanning trees use the diagonal edge • Since we must include an edge to each vertex of degree 2, we obtain four more spanning trees. • The total is eight. Ch. 2. Trees and Distance
Contraction 2.2.7 • In a graph G, contraction of edge ewith endpointsu, vis the replacement of uandvwith a single vertex whose incident edges are the edges other than ethat were incident touorv • The resulting graph G·ehas one less edge thanG u e G G·e v Ch. 2. Trees and Distance
Proposition. Let (G) denote the number of spanning trees of a graph G. If eE(G) is not a loop, then(G)= (G-e)+ (G·e) 2.2.8 • (G-e): The number of trees without e • (G·e): The number of trees with e • A spanning tree in G.e A spanning tree having einG G G-e e = G·e Ch. 2. Trees and Distance
Proposition. Let (G) denote the number of spanning trees of a graph G. If eE(G) is not a loop, then (G)= (G-e)+ (G·e) 2.2.8 Proof: 1/2 • The spanning trees of Gthat omit eare precisely the spanning trees ofG-e • Need to show thatGhas(G·e)spanning trees containing e • It must be shown that contraction of edefines a bijection from the set of spanning trees ofGcontaininge to the set of spanning trees of G·e Ch. 2. Trees and Distance
Proposition. Let (G) denote the number of spanning trees of a graph G. If eE(G) is not a loop, then (G)= (G-e)+ (G·e) 2.2.8 Proof:2/2 • When contract e in a spanning tree having e, obtain a spanning tree of G·e because • The resulting subgraph of G·e is spanning and connected • It has the right number of edges • The other edges maintain their identity under contraction • So no two trees are mapped to the same spanning tree of G·e by this operation. Ch. 2. Trees and Distance
A Matrix Tree computation. 2.2.12 • Given a loopless graph Gwith vertex set v1, …., vn • Let aijbe the number of edges with endpoints viand vj • LetQbe the matrix in which • entry (i, j) is –ai,jwhenij and is d(vi) wheni=j • Let Q* is a matrix obtained by deleting row s and column tofQ, then (G) = (-1)s+t detQ* Ch. 2. Trees and Distance
A Matrix Tree computation. 2.2.11 • Theorem 2.2.12 instructs us • Form a matrix by putting the vertex degrees on the diagonal and subtracting the adjacency matrix • Delete a row and a column and take the eterminant Ch. 2. Trees and Distance
A Matrix Tree computation. 2.2.11 • Consider the kite of Example 2.2.9, • The vertex degrees are 3,3,2,2 • We form the matrix on the left below and then • We take the determinant of the matrix in the middle • The result is the number of spanning trees Ch. 2. Trees and Distance
Example 2.2.11 v3 v1 v4 v2 v1 v2 v3 v4 v1 v2 v3 v4 8 Ch. 2. Trees and Distance
Minimum Spanning Tree 2.3 • In a connected weighted graph of possible communication links, all spanning trees have n-1edges; we seek one that minimizes or maximizes the sum of the edge weights. • Kruskal’s Algorithm • Prim’s Algorithm Ch. 2. Trees and Distance
Kruskal’s Algorithmfor Minimum Spanning Tree 2.3.1 • Input: A weighted connected graph • Idea: • Maintain an acyclic spanning subgraph H. • Enlarging it by edges with low weight to form a spanning tree. • Consider edges in nondecreasing order of weight. Ch. 2. Trees and Distance
Kruskal’s Algorithmfor Minimum Spanning Tree 2.3.1 • Initialization: SetE(H)=. • Iteration: If the next cheapest edge joins two components ofH, then include it; otherwise, discard it. Terminate whenHis connected. H Join Two vertices in one component. Cycle occurs. Not Allowed! Join two components. It works Ch. 2. Trees and Distance
Example of using Kruskal’s Algorithm 9 9 9 2 2 8 8 4 1 2 4 1 8 4 1 6 7 6 7 6 7 5 5 5 10 10 10 11 3 11 3 11 3 12 12 12 9 9 9 2 8 4 1 2 2 1 8 4 8 4 1 7 6 6 7 7 6 5 10 10 5 5 3 11 11 3 11 3 10 12 12 12 Ch. 2. Trees and Distance
Theorem: In a connected weighted graph G, Kruskal’s Algorithm constructs a minimum-weight spanning tree. 2.3.3 Proof: 1/3 • We show first that the algorithm produces a tree • We never choose an edge that completes a cycle • If the final graph has more than one component, then there is no edge joining two of them and G is not connected • Since G is connected, some such edge exists and we considered it. • Thus the final graph is connected and acyclic, which makes it a tree. Ch. 2. Trees and Distance
Theorem2.3.3 Continue Proof: continue • LetTbe the resulting tree, and let T*be a spannig tree of minimum weight. • IfT=T*, we are done. • IfTT*, let e be the first edge chosen for Tthat is not in T*. Adding etoT*creates one cycle C. Since Thas no cycle, Chas an edge e’E(T). Consider the spanning tree T*+e-e’ The first edge chosen for T that is not in T* T: …………. e, ………… T*: …………. e*,………… Identical Ch. 2. Trees and Distance
Theorem2.3.3 Continue Proof: continue • SinceT*containse’and all the edges of Tchosen before e, bothe’and eare available when the algorithm chooses e, and hence w(e)w(e’) • ThusT*+e-e’is a spanning tree with weight at mostT*that agrees with Tfor a longer initial list of edges thanT*does. T: ………….e, ………… T*: ………….e*,………… Identical T: …………… e, ………… T*+e-e’: …………… e, ………… Identical Ch. 2. Trees and Distance
Theorem2.3.3 Continue Proof: continue • Repeating this argument eventually yields a minimum-weight spanning tree that agrees completely withT. • Phrased extremely, we have proved that the minimum spanning tree agreeing withTthe longest is Titself. Ch. 2. Trees and Distance
Shortest Paths • How can we find the shortest route from one location to another? Ch. 2. Trees and Distance