0% found this document useful (0 votes)
23 views51 pages

Lecture-36 Teacher

lecture 36
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views51 pages

Lecture-36 Teacher

lecture 36
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 51

Section 10.

Graph Terminology and


Special Types of Graphs
Section Summary

 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}

N(A) = {d}U{c,e} = {d,c,e}


Basic Terminology

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

Example: What are the degrees and neighborhoods of the vertices in


the graphs G and H?

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) =  .

H: deg(a) = 4, deg(b) = deg(e) = 6, deg(c) = 1, deg(d) = 5.


N(a) = {b, d, e}, N(b) = {a, b, c, d, e}, N(c) = {b},N(d) = {a, b,
e}, N(e) = {a, b ,d}.
Basic Terminology

THEOREM 1:
(The Handshaking Theorem) Let G = (V, E) be an undirected
graph with m edges. Then

2m  deg(v)
vV
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.

Proof: Let V1 be the vertices of even degree and V2 be the vertices of


odd degree in an undirected graph G = (V, E) with m edges. Then

even

This sum must be even because 2m is


even and the sum of the degrees of the
vertices of even degrees is also even.
even for each v ∈ V1
must be even since deg(v) is
Because this is the sum of the degrees
of all vertices of odd degree in the
graph, there must be an even number
of such vertices.
Basic Terminology
(Directed Graph)

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.

*The initial and terminal vertices of a loop are the same.


Basic Terminology
(Directed Graph)

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)

A complete graph on n vertices, denoted by Kn, is the simple graph


that contains exactly one edge between each pair of distinct vertices.
Special Types of Simple Graphs
(Cycles and Wheels)

A cycle Cn for n ≥ 3 consists of n vertices v1, v2 ,⋯ , vn, and edges {v1,


v2}, {v2, v3} ,⋯ , {vn-1, vn}, {vn, v1}.

A wheel Wn is obtained by adding an additional vertex to a cycle Cn for


n ≥ 3 and connecting this new vertex to each of the n vertices in Cn by
new edges.
Special Types of Simple Graphs
(n-Cubes)
An n-dimensional hypercube, or n-cube, Qn, is a graph with 2n
vertices representing all bit strings of length n, where there is an edge
between two vertices that differ in exactly one bit position.
Bipartite 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

It is not hard to show that an equivalent definition of a bipartite graph is


a graph where it is possible to color the vertices red or blue so that no
two adjacent vertices are the same color.

G is bipartite H is not bipartite


Bipartite Graphs
(Complete 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.

Example: We display four complete bipartite graphs here.


Bipartite Graphs and Matching
(job Assignment)

 Application of Bipartite Graphs-


– matching the elements of one set to elements of another

 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)

 We now consider two different scenarios.


 Objective:
– assign an employee to each job so that every job has an employee assigned to it, and
– so that no employee is assigned more than one job.
Bipartite Graphs and Matching
(Job assignment)
 Scenario -1: Project 1

We can do this by assigning-


Alvarez to testing,
Berkowitz to implementation,
Chen to architecture, and
Davis to requirements,
as shown in Figure 10(a) (where blue lines show this assignment of jobs).
Bipartite Graphs and Matching
(Job assignment)
 Scenario -2: Project 2

Impossible to fulfill the objective.

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.

a • Is M={(a,1), (b,2)} a maximal matching?


• Answer: No
1
• M is subset of N ={(a,1),(b,2),(c.3).
b • N is maximal matching.
2
• Is M = {(c,1),(b,2)} a maximal matching?
c • Answer: Yes
3
• M = ={(a,1),(b,2),(c.3) is a maximum matching
and maximal matching too
Bipartite Graphs and Matchings
 Definition-
– A matching M in a bipartite graph G = (V, E) with bipartition (V1, V2) is a complete matching
from V1 to V2 if every vertex in V1 is the endpoint of an edge in the matching, or equivalently, if |M|
= |V1|.

a • M={(a,1),(b,2), (c,3)} is a matching


1 • G = (V,E) is a bipartite graph
b
• |M| = 3, |V1|=3
2 • M is a complete matching.
c
3
Bipartite Graphs and Matching
 Necessary And Sufficient Conditions For Complete Matching
– Determine whether a complete matching from V1 to V2 exists when (V1, V2) is a
bipartition of a bipartite graph G = (V, E)
– A theorem proved by Philip Hall in 1935.

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.

 Part-1: (graphical View)

a
1
a b
Since a complete matching
1
exists, 2
b |V1| ≥|V2| c
2 3
c
3 4

Complete Matching G(V,E)- bipartite graph


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: 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

 We have shown that in both cases there is a complete matching from


W1 to W2. This completes the inductive step and completes the
proof.
Some Applications of Special
Types of Graphs
 Local Area Networks
Some Applications of Special
Types of Graphs
 Interconnection Networks for Parallel Computation
New Graphs from Old
(Subgraph)

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,

• {b,c} and {b,e}


Original Graph Delete New replaced by
e,c, and vertex w {b,w}
{e,c} • {d,e} replaced
by {d,w}
New Graphs from Old
(Removing Vertices From A Graph)
 Remove a vertex v and all edges incident to it from G = (V, E),
– Produce a subgraph, denoted by G - v.
– Observe that G - v = (V - v, E’), where E’ is the set of edges of G not incident to v.

 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

union of G1 and G2 is denoted by G1 ⋃ G2.

Example:
Query???

1  2  3  4.... xy ( x  y ) ?

  1
 x 1 x ?  x 1
?
x

 x (  | x ) ? xy ( x  y ) ?

 1
1  2  3  4.... ?
1  1  1  1  1......... ?
 x 1
x
?

You might also like