COMPSCI 102 Introduction to Discrete Mathematics.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics and Its Applications
Advertisements

CS 336 March 19, 2012 Tandy Warnow.
Great Theoretical Ideas in Computer Science
Great Theoretical Ideas in Computer Science for Some.
Graphs, Planar graphs Graph coloring
 Theorem 5.9: Let G be a simple graph with n vertices, where n>2. G has a Hamilton circuit if for any two vertices u and v of G that are not adjacent,
Chapter 9 Graphs.
Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
Great Theoretical Ideas in Computer Science for Some.
CompSci 102 Discrete Math for Computer Science April 19, 2012 Prof. Rodger Lecture adapted from Bruce Maggs/Lecture developed at Carnegie Mellon, primarily.
Great Theoretical Ideas in Computer Science.
Last time: terminology reminder w Simple graph Vertex = node Edge Degree Weight Neighbours Complete Dual Bipartite Planar Cycle Tree Path Circuit Components.
1 Representing Graphs. 2 Adjacency Matrix Suppose we have a graph G with n nodes. The adjacency matrix is the n x n matrix A=[a ij ] with: a ij = 1 if.
Applied Combinatorics, 4th Ed. Alan Tucker
What is the next line of the proof? a). Let G be a graph with k vertices. b). Assume the theorem holds for all graphs with k+1 vertices. c). Let G be a.
Computational Geometry Seminar Lecture 1
Definition Hamiltonian graph: A graph with a spanning cycle (also called a Hamiltonian cycle). Hamiltonian graph Hamiltonian cycle.
Graph Colouring Lecture 20: Nov 25.
Is the following graph Hamiltonian- connected from vertex v? a). Yes b). No c). I have absolutely no idea v.
Definition Dual Graph G* of a Plane Graph:
Drawing of G. Planar Embedding of G Proposition Proof. 1. Consider a drawing of K 5 or K 3,3 in the plane. Let C be a spanning cycle. 2. If the.
Curve Curve: The image of a continous map from [0,1] to R 2. Polygonal curve: A curve composed of finitely many line segments. Polygonal u,v-curve: A polygonal.
CS 2813 Discrete Structures
Matthew Bowling Euler’s Theorem Mathfest Spring ‘15.
Graph Theory Chapter 6 Planar Graphs Ch. 6. Planar Graphs.
Planar Graphs: Euler's Formula and Coloring Graphs & Algorithms Lecture 7 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
5.2 Trees  A tree is a connected graph without any cycles.
V Spanning Trees Spanning Trees v Minimum Spanning Trees Minimum Spanning Trees v Kruskal’s Algorithm v Example Example v Planar Graphs Planar Graphs v.
MAT 2720 Discrete Mathematics Section 8.7 Planar Graphs
Planar Graphs Graph Coloring
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.
5.8 Graph Matching  Example: Set of worker assign to a set of task  Four tasks are to be assigned to four workers.  – Worker 1 is qualified to do tasks.
Graph Colouring Lecture 20: Nov 25. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including.
Graph Theory and Applications
Graph theory and networks. Basic definitions  A graph consists of points called vertices (or nodes) and lines called edges (or arcs). Each edge joins.
MAT 2720 Discrete Mathematics Section 8.2 Paths and Cycles
 Quotient graph  Definition 13: Suppose G(V,E) is a graph and R is a equivalence relation on the set V. We construct the quotient graph G R in the follow.
Chapter 9.7 Planar Graphs These class notes are based on material from our textbook, Discrete Mathematics and Its Applications, 6th ed., by Kenneth H.
Great Theoretical Ideas in Computer Science for Some.
Graphs. Representations of graphs : undirected graph An undirected graph G have five vertices and seven edges An adjacency-list representation of G The.
Great Theoretical Ideas In Computer Science
Great Theoretical Ideas In Computer Science
Planar Graphs Hubert Chan (Chapter 9.7) [O2 Proof Techniques]
Outline 1 Properties of Planar Graphs 5/4/2018.
Discrete Mathematics Graph: Planar Graph Yuan Luo
Great Theoretical Ideas In Computer Science
Applied Combinatorics, 4th Ed. Alan Tucker
Graph theory Definitions Trees, cycles, directed graphs.
Great Theoretical Ideas in Computer Science
Discrete Mathematics for Computer Science
Chapter 10.7 Planar Graphs These class notes are based on material from our textbook, Discrete Mathematics and Its Applications, 7th ed., by Kenneth H.
GRAPH SPANNERS.
Graphs Chapter 13.
Chapter 10.7 Planar Graphs These class notes are based on material from our textbook, Discrete Mathematics and Its Applications, 7th ed., by Kenneth H.
Chapter 10.7 Planar Graphs These class notes are based on material from our textbook, Discrete Mathematics and Its Applications, 7th ed., by Kenneth H.
Applied Combinatorics, 4th Ed. Alan Tucker
Chapter 10.7 Planar Graphs These class notes are based on material from our textbook, Discrete Mathematics and Its Applications, 7th ed., by Kenneth H.
Chapter 10.7 Planar Graphs These class notes are based on material from our textbook, Discrete Mathematics and Its Applications, 7th ed., by Kenneth H.
Theorem 5.13: For vT‘, l’(v)= min{l(v), l(vk)+w(vk, v)}
Great Theoretical Ideas In Computer Science
MAT 2720 Discrete Mathematics
Chapter 10.7 Planar Graphs These class notes are based on material from our textbook, Discrete Mathematics and Its Applications, 8th ed., by Kenneth H.
N(S) ={vV|uS,{u,v}E(G)}
GRAPHS Lecture 17 CS2110 Spring 2018.
Gaph Theory Planar Graphs
Discrete Mathematics for Computer Science
Chapter 10.7 Planar Graphs These class notes are based on material from our textbook, Discrete Mathematics and Its Applications, 7th ed., by Kenneth H.
Chapter 10.7 Planar Graphs These class notes are based on material from our textbook, Discrete Mathematics and Its Applications, 7th ed., by Kenneth H.
Presentation transcript:

COMPSCI 102 Introduction to Discrete Mathematics

Graphs Lecture 19 (November 5, 2007)

A tree is a connected graph with no cycles What’s a tree?

Tree

Not Tree

Tree

How Many n-Node Trees? 1: 2: 3: 4: 5:

Notation In this lecture: n will denote the number of nodes in a graph e will denote the number of edges in a graph

Theorem: Let G be a graph with n nodes and e edges The following are equivalent: 1. G is a tree (connected, acyclic) 3. G is connected and n = e G is acyclic and n = e G is acyclic and if any two non-adjacent points are joined by adding a new edge, the resulting graph has exactly one cycle 2. Every two nodes of G are joined by a unique path

To prove this, it suffices to show 1  2  3  4  5  1

1  2 1. G is a tree (connected, acyclic) 2. Every two nodes of G are joined by a unique path Proof: (by contradiction) Assume G is a tree that has two nodes connected by two different paths: Then there exists a cycle!

2  3 2. Every two nodes of G are joined by a unique path Proof: (by induction) Assume true for every graph with < n nodes 3. G is connected and n = e + 1 Let G have n nodes and let x and y be adjacent Let n 1,e 1 be number of nodes and edges in G 1 Then n = n 1 + n 2 = e 1 + e = e + 1 x y G1G1 G2G2

3  4 Proof: (by contradiction) Assume G is connected with n = e + 1, and G has a cycle containing k nodes 3. G is connected and n = e G is acyclic and n = e + 1 k nodes Note that the cycle has k nodes and k edges Starting from cycle, add other nodes and edges until you cover the whole graph Number of edges in the graph will be at least n

Corollary: Every nontrivial tree has at least two endpoints (points of degree 1) Proof: Assume all but one of the points in the tree have degree at least 2 Then the total number of edges in the tree is at least (2n-1)/2 = n - 1/2 > n - 1 In any graph, sum of the degrees =2e

How many labeled trees are there with three nodes?

How many labeled trees are there with four nodes? a b c d

How many labeled trees are there with five nodes? 5 labelings labeled trees labelings

How many labeled trees are there with n nodes? 16 labeled trees with 4 nodes 3 labeled trees with 3 nodes 125 labeled trees with 5 nodes n n-2 labeled trees with n nodes

The number of labeled trees on n nodes is n n-2 Cayley’s Formula

The proof will use the correspondence principle Each labeled tree on n nodes corresponds to A sequence in {1,2,…,n} n-2 (that is, n-2 numbers, each in the range [1..n])

How to make a sequence from a tree? Example: Loop through i from 1 to n-2 Let L be the degree-1 node with the lowest label Define the i th element of the sequence as the label of the node adjacent to L Delete the node L from the tree

How to reconstruct the unique tree from a sequence S: Loop until S is empty Let i = smallest # in I but not in S Let s = first label in sequence S Add edge {i, s} to the tree Delete i from I Delete s from S Let I = {1, 2, 3, …, n} Add edge {a,b}, where I = {a,b}

Spanning Trees A spanning tree of a graph G is a tree that touches every node of G and uses only edges from G Every connected graph has a spanning tree

A graph is planar if it can be drawn in the plane without crossing edges

Examples of Planar Graphs =

Faces A planar graph splits the plane into disjoint faces 4 faces

Euler’s Formula If G is a connected planar graph with n vertices, e edges and f faces, then n – e + f = 2

Rather than using induction, we’ll use the important notion of the dual graph Dual = put a node in every face, and an edge between every adjacent face

Let G* be the dual graph of G Let T be a spanning tree of G Let T* be the graph where there is an edge in dual graph for each edge in G – T Then T* is a spanning tree for G* n = e T + 1 f = e T* + 1 n + f = e T + e T* + 2 = e + 2

Corollary: Let G be a simple planar graph with n > 2 vertices. Then: 1. G has a vertex of degree at most 5 2. G has at most 3n – 6 edges Proof of 1 (by contradiction): Then e ≥ 3n In any graph, (sum of degrees) = 2e Furthermore, since G is simple, 3f ≤ 2e Assume all vertices have degree ≥ 6 So 3n + 3f ≤ 3e, 3n + 3f = 3e + 6, and 3e + 6 ≤ 3e

A coloring of a graph is an assignment of a color to each vertex such that no neighboring vertices have the same color Graph Coloring

Arises surprisingly often in CS Register allocation: assign temporary variables to registers for scheduling instructions. Variables that interfere, or are simultaneously active, cannot be assigned to the same register

Theorem: Every planar graph can be 6- colored Proof Sketch (by induction): Assume every planar graph with less than n vertices can be 6-colored Assume G has n vertices Since G is planar, it has some node v with degree at most 5 Remove v and color by Induction Hypothesis

Not too difficult to give an inductive proof of 5-colorability, using same fact that some vertex has degree ≤ 5 4-color theorem remains challenging!

Implementing Graphs

Adjacency Matrix Suppose we have a graph G with n vertices. The adjacency matrix is the n x n matrix A=[a ij ] with: a ij = 1 if (i,j) is an edge a ij = 0 if (i,j) is not an edge Good for dense graphs!

Example A =

Counting Paths The number of paths of length k from node i to node j is the entry in position (i,j) in the matrix A k A 2 = =

Adjacency List Suppose we have a graph G with n vertices. The adjacency list is the list that contains all the nodes that each node is adjacent to Good for sparse graphs!

Example : 2,3 2: 1,3,4 3: 1,2,4 4: 2,3

Here’s What You Need to Know… Trees Counting Trees Different Characterizations Planar Graphs Definition Euler’s Theorem Coloring Planar Graphs Adjacency Matrix and List Definition Useful for counting