Lecture-36 Teacher
Lecture-36 Teacher
Basic Terminology
Some Special Types of Graphs
Bipartite Graphs
Bipartite Graphs and Matching's
Some Applications of Special Types of Graphs
New Graphs from Old
Basic Terminology
DEFINITION 1.
Two vertices u, v in an undirected graph G are called adjacent (or
neighbors) in G if there is an edge e between u and v.
Such an edge e is called incident with the vertices u and v
e is said to connect u and v.
Basic Terminology
DEFINITION 2.
– The set of all neighbors of a vertex v of G = (V, E), denoted by
N(v), is called the neighborhood of v.
– If A is a subset of V, we denote by N(A) the set of all vertices in G
that are adjacent to at least one vertex in A. So,
N(a) = {b,c}
Let A = {a,b}
DEFINITION 3.
– The degree of a vertex in a undirected graph is the number of
edges incident with it, except that a loop at a vertex contributes
two to the degree of that vertex.
– The degree of the vertex v is denoted by deg(v).
deg(a) = 2
Basic Terminology
Solution:
G: deg(a) = 2, deg(b) = deg(c) = deg(f ) = 4, deg(d ) = 1,
deg(e) = 3, deg(g) = 0.
N(a) = {b, f }, N(b) = {a, c, e, f }, N(c) = {b, d, e, f }, N(d) = {c},
N(e) = {b, c , f }, N(f) = {a, b, c, e}, N(g) = .
THEOREM 1:
(The Handshaking Theorem) Let G = (V, E) be an undirected
graph with m edges. Then
2m deg(v)
vV
Proof:
Each edges contributes twice to the degree count of all vertices.
Hence both the left-hand and right-hand sides of the equation
equal twice the number of edges.
Think About the graph where vertices represent the people at a party and an edge connect
two people who have shaken hands.
Basic Terminology
(Handshaking Theorem)
Example:
How many edges are there in a graph with 10 vertices of degree 6?
Solution:
Because the sum of the degrees of the vertices is 6 10 = 60,
the handshaking theorem tells us that 2m = 60.
So the number of edges m = 30.
Basic Terminology
(Handshaking Theorem)
Example:
If a graph has 5 vertices, can each vertex have degree 3?
Solution:
This is not possible by the handshaking thorem,
because the sum of the degrees of the vertices 3 5 = 15 is odd.
Basic Terminology
(Handshaking Theorem)
THEOREM 2:
An undirected graph has an even number of vertices of odd
degree.
even
DEFINITION 4.
– Let (u,v) be an edge in G with directed edge.
– u is the initial vertex of this edge
– u is adjacent to v
– v is the terminal (or end) vertex of this edge
– v is adjacent from u.
DEFINITION 5
• The in-degree of a vertex v, denoted deg−(v), is the number of edges
which terminate at v.
• The out-degree of v, denoted deg+(v), is the number of edges with v as
their initial vertex.
• Note that a loop at a vertex contributes 1 to both the in-degree and the
out-degree of the vertex.
Example:
In the graph G we have
deg−(a) = 2, deg−(b) = 2, deg−(c) = 3, deg−(d) = 2, deg−(e) = 3, deg−(f) = 0.
deg+(a) = 4, deg+(b) = 1, deg+(c) = 2, deg+(d) = 2, deg+ (e) = 3, deg+(f) = 0.
Basic Terminology
(Directed Graph)
THEOREM 3:
Let G = (V, E) be a graph with directed edges. Then:
Special Types of Simple Graphs
(Complete Graphs)
DEFINITION.
– A simple graph G is bipartite if V can be partitioned into two
disjoint subsets V1 and V2 such that every edge connects a
vertex in V1 and a vertex in V2.
– In other words, there are no edges which connect two vertices in
V1 or in V2.
Bipartite Graphs
Example:
Show that C6 is bipartite.
Solution:
We can partition the vertex set into V1 = {v1, v3, v5} and V2 = {v2,
v4, v6} so that every edge of C6 connects a vertex in V1 and V2 .
Bipartite Graphs
Example:
Show that C3 is not bipartite.
Solution:
–If we divide the vertex set of C3 into two nonempty sets, one of the
two must contain two vertices.
–But in C3 every vertex is connected to every other vertex.
–Therefore, the two vertices in the same partition are connected.
–Hence, C3 is not bipartite.
Bipartite Graphs
THEOREM 4
A simple graph is bipartite if and only if it is possible to assign
one of two different colors to each vertex of the graph so that no
two adjacent vertices are assigned the same color.
Proof:
–First, suppose that G = (V, E) is a bipartite simple graph.
–Then V = V1 ∪ V2, where V1 and V2 are disjoint sets and every
edge in E connects a vertex in V1 and a vertex in V2.
–If we assign one color to each vertex in V1 and a second color to
each vertex in V2, then no two adjacent vertices are assigned the
same color.
Bipartite Graphs
THEOREM 4
A simple graph is bipartite if and only if it is possible to assign one of
two different colors to each vertex of the graph so that no two
adjacent vertices are assigned the same color.
Proof:
–Now suppose that it is possible to assign colors to the vertices of the
graph using just two colors so that no two adjacent vertices are assigned
the same color.
–Let V1 be the set of vertices assigned one color and V2 be the set of
vertices assigned the other color.
–Then, V1 and V2 are disjoint and V = V1 ∪ V2.
–Furthermore, every edge connects a vertex in V1 and a vertex
in V2 because no two adjacent vertices are either both in V1 or both in
V2.
–Consequently, G is bipartite
Bipartite Graphs
DEFINITION:
A complete bipartite graph Km,n is a graph that has its vertex set
partitioned into two subsets V1 of size m and V2 of size n such that
there is an edge from every vertex in V1 to every vertex in V2.
Job Assignments –
– Suppose that there are m employees in a group and n different jobs
that need to be done, where m ≥ n.
– Each employee is trained to do one or more of these n jobs.
– We represent each employee by a vertex and each job by a vertex.
– For each employee, we include an edge from that employee to all jobs
that the employee has been trained to do.
– This graph is bipartite, where the bipartition is (E, J) where E is the
set of employees and J is the set of jobs.
Bipartite Graphs and Matching
(Job Assignment)
Xuan and Ziegler, who have been trained for at least one of the three jobs
of requirements, implementation, and testing. Consequently, there is no way
to assign three different employees to these three job so that each job is
assigned an employee with the appropriate training.
Bipartite Graphs and Matchings
Definition-
– Let a simple graph G=(V,E)
– Matching M in G is a subset of the set E of edges of the graph such that no two edges are
incident with the same vertex.
a • M={(a,1),(b,2)} is a matching
1 • M={(a,1),(c,2)} is an another matching
b • M={(b,2), (c,1)} is a matching
• M = {(b,2)} is a matching
2
c • M = {(a,1),(c,1)} is not a matching
In other words, a matching is a subset of edges such that if {s, t} and {u, v} are distinct
edges of the matching, then s, t, u, and v are distinct.
Bipartite Graphs and Matchings
Definition-
– A vertex that is the endpoint of an edge of a matching M is said to be matched in M;
– Otherwise it is said to be unmatched
a • M={(a,1),(b,2)} is a matching
1 • a is a matched vertex
b • c is a unmatched vertex
2
c
Bipartite Graphs and Matchings
Definition-
– A matching which is not proper subset of any matching is called maximal matching.
– A maximum matching is a matching with the largest number of edges.
Theorem: (Hall’s Marriage Theorem) The bipartite graph G = (V, E) with bipartition (V1, V2)
has a complete matching from V1 to V2 if and only if |N(A)| ≥ |A| for all subsets A of V1
a • A = {a,b} is subset of V1
1 • N(A) = {1,2}, |N(A)|=2, |A|=2
b • So |N(A)|≥|A| is true for a subset
• There are 23=8 subset available.
2
c
3
Bipartite Graphs and Matching
Proof:
– Part-1: If there is a complete matching M from V1 to V2, then |N(A)| ≥ |A| for all subsets A
of V1
– Part-2: If |N(A)| ≥ |A| for all subsets A of V1, Then there is a complete matching M from V1
to V2.
Part-1:
– Suppose that there is a complete matching M from V1 to V2.
– Then, if A ⊆ V1(proper subset), for every vertex v ∈ A, there is an edge (independent) in
M connecting v ∈ V2.
– Consequently, there are at least as many vertices in V2 as there are vertices in V1.
Because vertices V2 are neighbor of those vertices in V1.
–
Bipartite Graphs and Matching
Proof:
– Part-1: If there is a complete matching M from V1 to V2, then |N(A)| ≥ |A| for all subsets A of V1
– Part-2: If |N(A)| ≥ |A| for all subsets A of V1, Then there is a complete matching M from V1 to V2.
a
1
a b
Since a complete matching
1
exists, 2
b |V1| ≥|V2| c
2 3
c
3 4
Proof:
– Part-1: If there is a complete matching M from V1 to V2, then |N(A)|
≥ |A| for all subsets A of V1
– Part-2: If |N(A)| ≥ |A| for all subsets A of V1, Then there is a
complete matching M from V1 to V2.
Part-1: a
– It follows that |N(A)| ≥ |A|. 1
b
2
c
3
4
Bipartite Graphs and Matching
Proof:
– Part-1: If there is a complete matching M from V1 to V2, then |N(A)| ≥ |A| for all subsets A of V1
– Part-2: If |N(A)| ≥ |A| for all subsets A of V1, Then there is a complete matching M from V1 to V2.
Part-2:
– Use strong induction on |V1| to prove this.
– Basis step:
• If |V1| = 1, then V1 contains a single vertex v0.
• |N({v0})| ≥ |{v0}| = 1,
• there is at least one edge connecting v0 and a vertex w0 ∈ V2.
• Any such edge forms a complete matching from V1 to V2.
Bipartite Graphs and Matching
Proof:
– Part-1: If there is a complete matching M from V1 to V2, then |N(A)| ≥ |A| for all subsets A of V1
– Part-2: If |N(A)| ≥ |A| for all subsets A of V1, Then there is a complete matching M from V1 to V2.
Part-2:
– Inductive step: We first state the inductive hypothesis.
– Inductive hypothesis:
• Let k be a positive integer. If G = (V, E) is a bipartite graph with bipartition (V1, V2), and |V1| = j ≤ k, then
there is a complete matching M from V1 to V2 whenever the condition that |N(A)| ≥ |A| for all A ⊆ V1 is
met.
Bipartite Graphs and Matching
Part-2:
– Now suppose that H = (W, F) is a bipartite graph with bipartition (W1, W2) and |W1| = k + 1.
– We will prove that the inductive holds using a proof by cases, using two case.
– Case (i) applies when for all integers j with 1 ≤ j ≤ k, the vertices in every set of j elements from W1 are
adjacent to at least j + 1 elements of W2. (Since |N(A)| ≥ |A| )
– Case (ii) applies when for some j with 1 ≤ j ≤ k there is a subset W’1 of j vertices such that there are
exactly j neighbors of these vertices in W2. (Since |N(A)| ≥ |A| )
– Because either Case (i) or Case (ii) holds, we need only consider these cases to complete the
inductive step.
Bipartite Graphs and Matching
Case(i):
– Suppose that for all integers j with 1 ≤ j ≤ k, the vertices in every
subset of j elements from W1 are adjacent to at least j + 1 elements
of W2.
– Then, we select a vertex v ∈ W1 and an element w ∈ N({v}), which
must exist by our assumption that |N({v}| ≥ |{v}| = 1.
– We delete v and w and all edges incident to them from H. This
produces a bipartite graph H’ with bipartition (W1 - {v}, W2 - {w}).
– Because |W1 - {v}| = k, the inductive hypothesis tells us there is a
complete matching from W1 - {v} to W2 - {w}.
– Adding the edge from v to w to this complete matching produces a
complete matching from W1 to W2.
Bipartite Graphs and Matching
Case(ii):
– Suppose that for some j with 1 ≤ j ≤ k, there is a subset W’1 of j
vertices such that a there are exactly j neighbors of these
vertices in W2.
– Let W’2 be the set of these neighbors. Then, by the inductive
hypothesis there is a complete matching from W’1 to W’2.
– Remove these 2j vertices from W1 and W2 and all incident edges
to produce a bipartite graph K with bipartition (W1 - W’1 , W2 -
W’2).
Bipartite Graphs and Matching
Case(ii):
– We will show that the graph K satisfies the condition |N(A)| ≥ |A| for all
subsets A of W1 - W’1.
– If not, there would be a subset of t vertices of W1 - W’1 where 1 ≤ t ≤ k + 1
– j such that the vertices in this subset have fewer than t vertices of W2 - W’2
as neighbors.
– Then, the set of j + t vertices of W1 consisting of these t vertices together
with the j vertices we removed from W1 has fewer than j + t neighbors in
W2, contradicting the hypothesis that |N(A)| ≥ |A| for all A ⊆ W1.
– Hence, by the inductive hypothesis, the graph K has a complete matching
– Combining this complete matching with the complete matching from W’1 to
W’2, we obtain a complete matching from W1 to W2
Bipartite Graphs and Matching
DEFINITION:
• A subgraph of a graph G = (V,E) is a graph (W,F), where W ⊂ V
and F ⊂ E.
• A subgraph H of G is a proper subgraph of G if H ≠ G.
Example:
Here we show K5 and one of its subgraphs.
New Graphs from Old
(Subgraph)
DEFINITION:
• Let G = (V, E) be a simple graph.
• The subgraph induced by a subset W of the vertex set V is the graph (W,F),
where the edge set F contains an edge in E if and only if both endpoints are in W.
Example:
Here we show K5 and the subgraph induced by W = {a,b,c,e}.
New Graphs from Old
(Removing Or Adding Edges Of A Graph )
Given a graph G = (V, E) and an edge e ∈ E, we can produce a subgraph of G
by removing the edge e.
The resulting subgraph, denoted by G - e,
It has the same vertex set V as G.
Its edge set is E - e.
Hence,
G - e = (V, E - {e}).
We can also add an edge e to a graph to produce a new larger graph when
this edge connects two vertices already in G.
Denote by G + e .
The new graph produced by adding a new edge e, connecting two previously
nonincident vertices, to the graph G Hence,
G + e = (V , E ∪ {e}).
New Graphs from Old
(Edge Contractions )
An edge contraction which
– removes an edge e with endpoints u and v
– merges u and v into a new single vertex w
– for each edge with u or v as an endpoint replaces the edge with w as endpoint in place
of u or v and with the same second endpoint,
Similarly, if V‘ is a subset of V , then the graph G – V’ is the subgraph (V – V’, E’), where E’ is the set of edges of G
not incident to a vertex in V’.
New Graphs from Old
(Graph Unions)
DEFINITION:
the simple graph with vertex set V1 ⋃ V2 and edge set E1 ⋃ E2. The
The union of two simple graphs G1 = (V1, E1) and G2 = (V2, E2) is
Example:
Query???
1 2 3 4.... xy ( x y ) ?
1
x 1 x ? x 1
?
x
x ( | x ) ? xy ( x y ) ?
1
1 2 3 4.... ?
1 1 1 1 1......... ?
x 1
x
?