Announcements CS311H: Discrete Mathematics Introduction to Graph Theory

Transcription

Announcements CS311H: Discrete Mathematics Introduction to Graph Theory
Announcements
CS311H: Discrete Mathematics
Introduction to Graph Theory
I
Homework 6 due now!
I
Midterm next lecture in class: number theory, crypto,
induction, recursion, combinatorics
I
Allowed to bring 3 cheat sheets
Instructor: I¸sıl Dillig
Instructor: I¸sıl Dillig,
CS311H: Discrete Mathematics
Introduction to Graph Theory
Instructor: I¸sıl Dillig,
1/31
Motivation
Introduction to Graph Theory
2/31
Example: Social Network as a Graph
I
Graph is a fundamental mathematical structure
in computer science
I
Nodes represent users (Michael,
Jessica, Stuart . . . )
I
Graph G = (V , E ) consists of a set of vertices
(nodes) V and edges E between these nodes
I
Edges represent friendship (e.g.,
Michael is friends with Jessica)
I
Lots of applications in many areas: web search,
transportation, biological models, . . .
I
Edge between nodes u and v is
written as (u, v )
I
Will encounter graphs and graph algorithms in
many different courses
I
e.g., (Sarah, Andrew) is an edge in
this graph.
Instructor: I¸sıl Dillig,
CS311H: Discrete Mathematics
Introduction to Graph Theory
Instructor: I¸sıl Dillig,
3/31
Terminology
Instructor: I¸sıl Dillig,
CS311H: Discrete Mathematics
CS311H: Discrete Mathematics
Introduction to Graph Theory
4/31
Question
Consider a graph G with vertices v1 , v2 , v3 , v4 and edges
(v1 , v2 ), (v2 , v3 ), (v1 , v3 ), (v2 , v4 ).
I
Two nodes u and v are adjacent if there exists
an edge between them (e.g., nodes 1 and 3)
I
An edge (u, v ) is incident with nodes u and v
1. Draw this graph.
I
Degree of a vertex v , written deg(v ), is the
number of edges incident with it
2. What is the degree of each vertex?
I
Neighborhood of a vertex is the set of vertices
adjacent to it
CS311H: Discrete Mathematics
Introduction to Graph Theory
Instructor: I¸sıl Dillig,
5/31
1
CS311H: Discrete Mathematics
Introduction to Graph Theory
6/31
Simple Graphs
Question
I
Graph contains a loop if any node is adjacent
to itself
Consider a simple graph G where two vertices A and B have the
same neighborhood.
I
A simple graph does not contain loops and
there exists at most one edge between any
pair of vertices
Which of the following statements must be true about G?
A. The degree of each vertex must be even.
I
Graphs that have multiple edges connecting
two vertices are called multi-graphs
I
Most graphs we will look at are simple graphs
Instructor: I¸sıl Dillig,
CS311H: Discrete Mathematics
Introduction to Graph Theory
B. Both A and B have a degree of 0.
C. There cannot be an edge between A and B .
Instructor: I¸sıl Dillig,
7/31
Handshaking Theorem
I
Is it possible to construct a graph with 5 vertices where each
vertex has degree 3?
I
Prove that every graph has an even number of vertices of odd
degree.
I
If n people go to a party and everyone shakes everyone else’s
hand, how many handshakes occur?
v ∈V
I
Intuition: Each edge contributes two to the sum of the degrees
I
Proof: By induction on the number of edges.
I
Base case:
I
Induction:
CS311H: Discrete Mathematics
Introduction to Graph Theory
9/31
Instructor: I¸sıl Dillig,
Directed Graphs
8/31
CS311H: Discrete Mathematics
Introduction to Graph Theory
10/31
In-Degree and Out-Degree of Directed Graphs
I
All graphs we considered so far are undirected
I
In undirected graphs, edge (u, v ) same as (v , u)
I
But sometimes necessary to assign directions to
edges (e.g., links from one webpage to another)
I
The in-degree of a vertex v , written deg− (v ), is the number
of edges going into v
I
A directed edge (arc) is an ordered pair (u, v )
(i.e., (u, v ) not same as (v , u))
I
deg− (a) =
I
The out-degree of a vertex v , written deg+ (v ), is the number
of edges leaving v
I
deg+ (a) =
I
Instructor: I¸sıl Dillig,
Introduction to Graph Theory
Applications of Handshaking Theorem
Let G = (V , E ) be a graph with m edges. Then:
X
deg(v ) = 2m
Instructor: I¸sıl Dillig,
CS311H: Discrete Mathematics
A directed graph is a graph with directed edges
CS311H: Discrete Mathematics
Introduction to Graph Theory
11/31
Instructor: I¸sıl Dillig,
2
CS311H: Discrete Mathematics
Introduction to Graph Theory
12/31
Handshaking Theorem for Directed Graphs
Subgraphs
Let G = (V , E ) be a directed graph. Then:
X
X
deg− (v ) =
deg+ (v ) = |E |
v ∈V
v ∈V
I
I
Instructor: I¸sıl Dillig,
P
P
v ∈V
v ∈V
CS311H: Discrete Mathematics
I
A graph G = (V , E ) is a subgraph of another graph
G 0 = (V 0 , E 0 ) if V ⊆ V 0 and E ⊆ E 0
I
Example:
I
Graph G is a proper subgraph of G 0 if G 6= G 0 .
deg− (v ) =
deg+ (v ) =
Introduction to Graph Theory
Instructor: I¸sıl Dillig,
13/31
Question
CS311H: Discrete Mathematics
Introduction to Graph Theory
14/31
Induced Subgraph
Consider a graph G with vertices {v1 , v2 , v3 , v4 } and edges
(v1 , v3 ), (v1 , v4 ), (v2 , v3 ).
I
Consider a graph G = (V , E ) and a set of vertices V 0 such
that V 0 ⊆ V
I
Graph G 0 is the induced subgraph of G with respect to V 0 if:
Which of the following are subgraphs of G?
1. G 0 contains exactly those vertices in V 0
1. Graph G1 with vertex v1 and edge (v1 , v3 )
2. For all u, v ∈ V 0 , edge (u, v ) ∈ G 0 iff (u, v ) ∈ G
2. Graph G2 with vertices {v1 , v3 } and edge (v1 , v3 )
I
3. Graph G3 with vertices {v1 , v3 } and no edges
Subgraph induced by vertices {C , D}:
4. Graph G4 with vertices {v1 , v2 } and edge (v1 , v2 )
Instructor: I¸sıl Dillig,
CS311H: Discrete Mathematics
Introduction to Graph Theory
15/31
Instructor: I¸sıl Dillig,
Complete Graphs
Introduction to Graph Theory
16/31
Bipartite graphs
I
I
CS311H: Discrete Mathematics
A complete graph is a simple undirected graph in which every
pair of vertices is connected by one edge.
A simple undirected graph G = (V , E ) is called bipartite if V
can be partitioned into two disjoint sets V1 and V2 such that
every edge in E connects a V1 vertex to a V2 vertex
C
A
D
B
I
Instructor: I¸sıl Dillig,
E
How many edges does a complete graph with n vertices have?
CS311H: Discrete Mathematics
Introduction to Graph Theory
Instructor: I¸sıl Dillig,
17/31
3
CS311H: Discrete Mathematics
Introduction to Graph Theory
18/31
Examples Bipartite and Non-Bi-partite Graphs
I
Questions about Bipartite Graphs
Is this graph bipartite?
A
B
I
I
Does there exist a complete graph that is also bipartite?
I
Consider a graph G with 5 nodes and 7 edges. Can G be
bipartite?
C
What about this graph?
A
E
C
D
B
Instructor: I¸sıl Dillig,
F
CS311H: Discrete Mathematics
Introduction to Graph Theory
19/31
Instructor: I¸sıl Dillig,
Graph Coloring
I
A coloring of a graph is the assignment of a
color to each vertex so that no two adjacent
vertices are assigned the same color.
Consider a graph G with vertices {v1 , v2 , v3 , v4 } and edges
(v1 , v2 ), (v1 , v3 ), (v2 , v3 ), (v2 , v4 ).
A graph is k -colorable if it is possible to color it
using k colors.
Which of the following are valid colorings for G?
I
e.g., graph on left is 3-colorable
20/31
I
Is it also 2-colorable?
1. v1 = red, v2 = green, v3 = blue
2. v1 = red, v2 = green, v3 = blue, v4 = red
The chromatic number of a graph is the least number of
colors needed to color it.
I
Introduction to Graph Theory
Question
I
I
CS311H: Discrete Mathematics
3. v1 = red, v2 = green, v3 = red, v4 = blue
What is the chromatic number of this graph?
Instructor: I¸sıl Dillig,
CS311H: Discrete Mathematics
Introduction to Graph Theory
Instructor: I¸sıl Dillig,
21/31
Examples
CS311H: Discrete Mathematics
Introduction to Graph Theory
22/31
Applications of Graph Coloring
I
Graph coloring has lots of applications, particularly in
scheduling.
I
Example: What’s the minimum number of time slots needed
so that no student is enrolled in conflicting classes?
What are the chromatic numbers for these graphs?
A
B
A
B
A
B
C
D
C
D
C
D
311
314
312
331
429
439
Instructor: I¸sıl Dillig,
CS311H: Discrete Mathematics
Introduction to Graph Theory
23/31
Instructor: I¸sıl Dillig,
4
CS311H: Discrete Mathematics
Introduction to Graph Theory
24/31
A Scheduling Problem
Bipartite Graphs and Colorability
I
The math department has 6 committees C1 , . . . , Cn that
meet once a month.
I
The committee members are:
Prove that a graph G = (V , E ) is bipartite if and only if it is
2-colorable.
C1 = {Allen, Brooks, Marg} C2 = {Brooks, Jones, Morton}
C3 = {Allen, Marg, Morton} C4 = {Jones, Marg, Morton}
C5 = {Allen, Brooks}
C6 = {Brooks, Marg, Morton}
I
Instructor: I¸sıl Dillig,
How many different meeting times must be used to guarantee
that no one has conflicting meetings?
CS311H: Discrete Mathematics
Introduction to Graph Theory
Instructor: I¸sıl Dillig,
25/31
Complete graphs and Colorability
CS311H: Discrete Mathematics
Introduction to Graph Theory
26/31
Degree and Colorability
Prove that any complete graph Kn has chromatic number n.
Theorem: Let G be a simple graph such that max degree(G) = n.
Then, G is n + 1-colorable.
Instructor: I¸sıl Dillig,
CS311H: Discrete Mathematics
Introduction to Graph Theory
27/31
Instructor: I¸sıl Dillig,
Degree and Colorability, cont.
Instructor: I¸sıl Dillig,
CS311H: Discrete Mathematics
CS311H: Discrete Mathematics
Introduction to Graph Theory
28/31
Star Graphs and Colorability
Introduction to Graph Theory
29/31
Instructor: I¸sıl Dillig,
5
I
A star graph Sn is a graph with one
vertex u at the center and the only edges
are from u to each of v1 , . . . , vn−1 .
I
Draw S2 , S3 , S4 , S5 .
I
What is the chromatic number of Sn ?
CS311H: Discrete Mathematics
Introduction to Graph Theory
30/31
Question About Star Graphs
Suppose we have two star graphs Sk and Sm . Now, pick a random
vertex from each graph and connect them with an edge.
Which of the following statements must be true about the
resulting graph G?
1. The chromatic number of G is 3
2. G is 2-colorable.
3. max degree(G) = max(k , m).
Instructor: I¸sıl Dillig,
CS311H: Discrete Mathematics
Introduction to Graph Theory
31/31
6