380 likes | 637 Views
Trees and Connectivity. Lecture 9: Oct 10. (based on slides in MIT 6.042). v. ). (. Paths and Cycles. Simple Path : all vertices different. A simple cycle is a cycle that doesn’t cross itself. w. Every vertex is of degree exactly 2. cycle: v ··· w ··· v. also: w ··· v ··· w.
E N D
Trees and Connectivity Lecture 9: Oct 10 (based on slides in MIT 6.042)
v ) ( Paths and Cycles Simple Path: all vertices different A simple cycle is a cycle that doesn’t cross itself w Every vertex is of degree exactly 2. cycle: v ···w ···v also: w ···v ···w
Tree Graphs with no cycles? A forest. Connected graphs with no cycles? A tree.
More Trees leaf leaf A leaf is a vertex of degree 1. A binary tree Even more leaves. More leaves.
Tree Characterization by Path Definition. A tree is a connected graph with no cycles. Can there be no path between u and v? NO Can there be more than one simple path between u and v? NO This will create cycles. v u How to prove it formally? Claim. In a tree, there is a unique simple path between every pair of vertices.
Tree Characterization by Path Definition. A tree is a connected graph with no cycles. Claim. In a tree, there is a unique simple path between every pair of vertices. Is the converse true? That is, are the above statements equivalent? YES Given a graph G, if there is a unique simple path between every pair of vertices, then G is a tree? YES • Suppose that G is not a tree. • Since there is a path between every pair of vertices, G is connected. • So G has a cycle C. • But then there are more than one simple paths between the vertices in C. • A contradiction (or proof the contrapositive).
Tree Characterization by Number of Edges Definition. A tree is a connected graph with no cycles. Can a tree has no leaves? NO Then every vertex has degree at least 2 (why?). Go to unvisited edges as long as possible. Cannot get stuck, unless there is a cycle.
Tree Characterization by Number of Edges Definition. A tree is a connected graph with no cycles. Can a tree has no leaves? NO n-1? How many edges does a tree have? We usually use n to denote the number of vertices, and use m to denote the number of edges in a graph.
Tree Characterization by Number of Edges Definition. A tree is a connected graph with no cycles. Can a tree has no leaves? NO n-1? How many edges does a tree have? v Look at a leaf v. Is T-v a tree? YES • Can T-v has a cycle? • Is T-v connected? NO YES By induction, T-v has (n-1)-1=n-2 edges. So T has n-1 edges.
Tree Characterization by Number of Edges Definition. A tree is a connected graph with no cycles. Can a tree has no leaves? NO n-1 How many edges does a tree have? Is a graph with n-1 edges a tree? NO
Tree Characterization by Number of Edges Definition. A tree is a connected graph with no cycles. Can a tree has no leaves? NO n-1 How many edges does a tree have? YES Is a connected graph G with n-1 edges a tree? • There must be a vertex v of degree 1 (why?). • G-v is a connected graph (why?) with n-2 edges. • By induction, G-v is a tree. • So G is a tree. If every vertex has degree at least 2, then there are >= n edges.
Tree Characterization by Number of Edges Definition. A tree is a connected graph with no cycles. Can a tree has no leaves? NO n-1 How many edges does a tree have? YES Is a connected graph G with n-1 edges a tree? NO Can a tree has only one leaf? Handshaking lemma. • Every other vertex has degree at least 2. • One vertex has degree at least 3 (why?). • So number of edges >= (1 + 2 + 2 +…+ 2 + 3)/2 = n. • A contradiction.
B Cut Edges and Cycles Definition. An edge is a cut edge if its removal disconnects the graph. A Aisnot a cut edge. B is a cut edge. Claim:An edge is not a cut edge iff it is traversed by a simple cycle.
Tree Characterization by Connectivity Definition. A tree is a connected graph with no cycles. Definition. An edge is a cut edge if its removal disconnects the graph. Is an edge in a tree always a cut edge? YES Otherwise there was a cycle. Is a tree a minimally connected graph? YES
Tree Characterizations Definition. A tree is a connected graph with no cycles. Characterization by paths: A graph is a tree if and only if there is a unique simple path between every pair of vertices. Characterization by number of edges: A graph is a tree if and only if it is connected and has n-1 edges. Characterization by connectivity: A graph is a tree if and only if it is connected and every edge is a cut edge.
Spanning Trees A spanning tree: a subgraph that is a tree on all the vertices. A connected graph always has a spanning tree? YES A connected graph has at least n-1 edges? YES
Number of Spanning Trees A connected graph has a unique spanning tree? NO How many spanning trees in a cycle? n How many edges in a complete graph? n(n-1)/2 How many spanning trees in a complete graph? How many non-isomorphic spanning trees in a complete graph? (from Wolfram MathWorld)
vi vi+1 v0 … v0 v1 v2 vn-1 vn Paths and cycles in directed graphs Paths are directed: v0, v1,…, vn where vivi+1 for all i. A directed cycle if v0=vn
Directed Acyclic Graphs Definition. A directed acyclic graph is a directed graph with no directed cycles. A directed acyclic graph has at most n-1 edges? NO How many edges can a directed acyclic graph has? Every edge! 1 2 3 Given a directed graph with m edges, does it have a subgraph with at least m/2 edges? YES 4 Find an arbitrary ordering, take forward or backward edges. 1 2 6 3 4 5
Directed Spanning Trees root indegree=1 outdegree=2 For every vertex, there is a directed path from the root. Every vertex, except the root, has degree exactly one. Exactly n-1 edges.
vi vi+1 v0 Strongly Connected Graphs Definition. A graph is strongly connected if for every pair of vertices (u,v), there is a directed path from u to v and a directed path from v to u. Strongly connected. Not strongly connected.
Graph Orientations • Each junction is a vertex. • Each edge is a road. • How to make every road an “one-way-road” so that everywhere can still be reached from everywhere?
Graph Orientations (The one way street problem) Given an undirected graph, assign a direction to each edge so that the resulting directed graph is strongly connected.
Graph Orientations When a graph has a strongly connected orientation? When a graph does not have a strongly connected orientation? A bridge (Robbins 1939) A graph has a strongly connected orientation if and only if there is no cut edge (bridge).
Graph Connectivity Reliable network design In a tree, every vertex is connected to every other vertex. But any failure disconnects the graph!
Graph Connectivity 3-edge-connected. Reliable network design A graph is k-edge-connected if the graph remains connected no matter which k-1 edges are removed
Graph Connectivity Efficient network design In a tree, every vertex is connected to every other vertex. But there is only one path, and so the transmission speed is slow.
Graph Connectivity 3-path-connected. Efficient network design A graph is k-path-connected if there are at least k edge-disjoint paths between every pair of vertices.
Graph Connectivity A graph is k-edge-connected if the graph remains connected no matter which k-1 edges are removed Reliable network design A graph is k-path-connected if there are at least k edge-disjoint paths between every pair of vertices. Efficient network design When k=1, they are equivalent. Which is easier? If removal of k edges disconnects G, then G is at most k-path-connected. k-path-connected => k-edge-connected
Graph Connectivity A graph is k-edge-connected if the graph remains connected no matter which k-1 edges are removed Reliable network design A graph is k-path-connected if there are at least k edge-disjoint paths between every pair of vertices. Efficient network design When k=1, they are equivalent. Which is easier? (Menger 1927) A graph is k-edge-connected iff it is k-path connected. This is a fundamental theorem in graph theory. At least how many edges in a k-edge-connected graph?