CS311H: Discrete Mathematics Combinatorics and Graph Theory

Summary of Different Permuations and Combinations
CS311H: Discrete Mathematics
Order matters?
Combinatorics and
Graph Theory
Question: How many ways to pick r objects from . . .
n objects
n types of objects
Permutation
Yes
P (n, r ) =
Instructor: Işıl Dillig
C (n, r ) =
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
1/37
Instructor: Işıl Dillig,
Permutations with Indistinguishable Objects
How many different strings can be made by reordering the
letters in the word ALL?
I
This is not given by 3! because some of the letters in this
word are the same
I
Different strings: ALL, LAL, LLA ⇒ 3 possibilities, not 6
because relative ordering of L’s doesn’t matter
I
In general, how can we compute the number of permutations
of n objects where some of them are indistinguishable?
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
I
I
3/37
n!
r !·(n−r )!
CS311H: Discrete Mathematics
C ∗ (n, r ) =
(n+r −1)!
r !·(n−1)!
Combinatorics and Graph Theory
2/37
Consider n objects such that:
I
n1 of them indistingishable of type 1
I
n2 of them indistingishable of type 2
I
...
I
nk of them indistinguishable of type k
The number of permutations in this case is given by:
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
4/37
Proof, cont.
I
Let’s decompose using product rule:
I
First, place all n1 objects of type 1
I
I
Then all n2 objects of type 2 etc.
I
How many ways to place n1 indistinguishable objects in n
slots?
I
Instructor: Işıl Dillig,
Combination w/ repetition
n!
n1 !n2 ! . . . nk !
Proof
I
P ∗ (n, r ) = n r
Permutations with Indistinguishable Objects, cont.
I
I
n!
(n−r )!
Combination
No
Permutation w/ repetition
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
5/37
Instructor: Işıl Dillig,
1
Now, how many ways to place n2 objects of type 2?
Continuing this way and using product rule, number of
permutations is:


kP
−1
n
n − n1
n − n1 − n2
n−
ni 

·
·
...
i=1
n2
n3
n1
nk
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
6/37
Proof, cont.
Example 1
I
n
n1


n − n1
n−
ni 
·
...
i=1
n2
nk
kP
−1
Let’s expand this definition:
I
How many different strings can be made by ordering the
letters of the word SUCCESS?
I
I
n!
n1 !n2 ! . . . nk !
I
This simplifies to:
I
Another way to see this: Compute total # of permutations (n!) and
then divide by # of relative orderings between objects of type 1
(n1 !), # of relative orderings of objects of type 2 (n2 !) etc.
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
Instructor: Işıl Dillig,
7/37
Example 2
There are 3 identical red balls, 5 identical blue balls, and 2
identical green balls.
I
In how many different ways can these balls be arranged if the
first ball must be blue?
I
Many counting problems can be thought of as distributing
objects into boxes
I
In some cases both objects and boxes are distinguishable
I
In some cases, boxes are distinguishable, but objects are
indistinguishable
I
I
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
Instructor: Işıl Dillig,
9/37
Example: Distinguishable Objects in Distinguishable Boxes
I
Combinatorics and Graph Theory
8/37
Distributing Objects into Boxes
I
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
10/37
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
12/37
Example, cont.
How many ways are there to distribute 5 cards to each of 4
players from a deck of 52 cards?
I
I
I
I
I
I
I
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
11/37
Instructor: Işıl Dillig,
2
Indistinguishable Objects Into Distinguishable Boxes
I
Distributing Objects into Boxes Summary
How many ways are there to place 10 indistinguishable balls
into 8 distinguishable bins?
I
Distinguishable objects into distinguishable boxes:
I
I
I
I
Involves permutations
Indistinguishable objects into distinguishable boxes:
I
Involves combination
I
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
Instructor: Işıl Dillig,
13/37
Another Example
I
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
14/37
Example 2
How many ways to distribute six distinguishable objects to five
distinguishable boxes?
I
I
How many ways to distribute six indistinguishable objects to
five distinguishable boxes?
I
I
I
I
I
I
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
Instructor: Işıl Dillig,
15/37
Example 3
I
CS311H: Discrete Mathematics
16/37
New Topic: Graphs
How many ways to assign 15 distinguishable objects into 5
distinguishable boxes so boxes contain 1, 2, 3, 4, 5 objects
respectively?
I
I
Graph is a fundamental mathematical structure
in computer science
I
Graph G = (V , E ) consists of a set of vertices
(nodes) V and edges E between these nodes
I
Lots of applications in many areas: web search,
transportation, biological models, . . .
I
Will encounter graphs and graph algorithms in
many different courses
I
Instructor: Işıl Dillig,
Combinatorics and Graph Theory
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
17/37
Instructor: Işıl Dillig,
3
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
18/37
Example: Social Network as a Graph
Instructor: Işıl Dillig,
Terminology
I
Nodes represent users (Michael,
Jessica, Stuart . . . )
I
Two nodes u and v are adjacent if there exists
an edge between them (e.g., nodes 1 and 3)
I
Edges represent friendship (e.g.,
Michael is friends with Jessica)
I
An edge (u, v ) is incident with nodes u and v
I
Edge between nodes u and v is
written as (u, v )
I
Degree of a vertex v , written deg(v ), is the
number of edges incident with it
I
e.g., (Sarah, Andrew) is an edge in
this graph.
I
Neighborhood of a vertex is the set of vertices
adjacent to it
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
Instructor: Işıl Dillig,
19/37
Question
CS311H: Discrete Mathematics
20/37
Simple Graphs
Consider a graph G with vertices v1 , v2 , v3 , v4 and edges
(v1 , v2 ), (v2 , v3 ), (v1 , v3 ), (v2 , v4 ).
1. Draw this graph.
I
Graph contains a loop if any node is adjacent
to itself
I
A simple graph does not contain loops and
there exists at most one edge between any
pair of vertices
I
Graphs that have multiple edges connecting
two vertices are called multi-graphs
I
Most graphs we will look at are simple graphs
2. What is the degree of each vertex?
Instructor: Işıl Dillig,
Combinatorics and Graph Theory
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
21/37
Instructor: Işıl Dillig,
Question
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
22/37
Handshaking Theorem
Let G = (V , E ) be a graph with m edges. Then:
X
deg(v ) = 2m
Consider a simple graph G where two vertices A and B have the
same neighborhood.
v ∈V
Which of the following statements must be true about G?
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:
A. The degree of each vertex must be even.
B. Both A and B have a degree of 0.
C. There cannot be an edge between A and B .
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
Instructor: Işıl Dillig,
23/37
4
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
24/37
Applications of 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.
If n people go to a party and everyone shakes everyone else’s
hand, how many handshakes occur?
I
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
Directed Graphs
25/37
I
All graphs we considered so far are undirected
I
In undirected graphs, edge (u, v ) same as (v , u)
I
A directed edge (arc) is an ordered pair (u, v )
(i.e., (u, v ) not same as (v , u))
I
A directed graph is a graph with directed edges
Instructor: Işıl Dillig,
In-Degree and Out-Degree of Directed Graphs
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
26/37
Handshaking Theorem for Directed Graphs
Let G = (V , E ) be a directed graph. Then:
X
X
deg− (v ) =
deg− (v ) = |E |
v ∈V
I
The in-degree of a vertex v , written deg− (v ), is the number
of edges going into v
I
I
I
deg− (a) =
I
The out-degree of a vertex v , written deg+ (v ), is the number
of edges leaving v
I
deg+ (a) =
Instructor: Işıl Dillig,
v ∈V
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
27/37
Instructor: Işıl Dillig,
Subgraphs
P
P
CS311H: Discrete Mathematics
v ∈V
v ∈V
deg− (v ) =
deg+ (v ) =
Combinatorics and Graph Theory
28/37
Question
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
Consider a graph G with vertices {(v1 , v2 , v3 , v4 )} and edges
(v1 , v3 ), (v1 , v4 ), (v2 , v3 ).
I
Example:
Which of the following are subgraphs of G?
1. Graph G1 with vertex v1 and edge (v1 , v3 )
2. Graph G2 with vertices {v1 , v3 } and edge (v1 , v3 )
3. Graph G3 with vertices {v1 , v3 } and no edges
I
Instructor: Işıl Dillig,
4. Graph G4 with vertices {v1 , v2 } and edge (v1 , v2 )
Graph G is a proper subgraph of G 0 if G 6= G 0 .
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
29/37
Instructor: Işıl Dillig,
5
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
30/37
Induced Subgraph
Complete Graphs
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:
I
A complete graph is a simple undirected graph in which every
pair of vertices is connected by one edge.
I
How many edges does a complete graph with n vertices have?
1. G 0 contains exactly those vertices in V 0
2. For all u, v ∈ V 0 , edge (u, v ) ∈ G 0 iff (u, v ) ∈ G
I
Subgraph induced by vertices {C , D}:
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
Instructor: Işıl Dillig,
31/37
Bipartite graphs
I
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
Examples Bipartite and Non-Bi-partite Graphs
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
I
Is this graph bipartite?
A
C
B
A
D
I
C
What about this graph?
A
B
32/37
E
E
C
D
B
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
33/37
Instructor: Işıl Dillig,
Graph Coloring
I
Instructor: Işıl Dillig,
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
I
34/37
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
Combinatorics and Graph Theory
Question
I
I
CS311H: Discrete Mathematics
F
3. v1 = red, v2 = green, v3 = red, v4 = blue
What is the chromatic number of this graph?
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
35/37
Instructor: Işıl Dillig,
6
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
36/37
Examples
What are the chromatic numbers for these graphs?
A
B
A
B
A
B
C
D
C
D
C
D
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Combinatorics and Graph Theory
37/37
7