Lec 20
Lec 20
Summer 2017
Lecture 20 - Outline
July 6, 2017
Graphs
A graph, consists of two sets, a non-empty set, V , of vertices or nodes, and a possibly empty set,
E, of 2-element subsets of V . Such is graph is denoted by G = (V, E).
Each element of E is called an edge. We say that an edge {u, v} ∈ E connects vertices u and
v. Two vertices u and v are adjacent if {u, v} ∈ E. An edge {u, v} is said to be incident on the
vertex u and incident on the vertex v.
Vertices adjacent to a vertex u are called neighbors of u. The number of neighbors of a vertex
v is called the degree of v and is denoted by deg(v). The minimum degree, denoted δ(G), of
a graph G is the degree of the vertex in the graph G with the smallest degree. The maximum
degree, denoted ∆(G), of a graph G is the degree of the vertex in the graph G with the largest
degree.
An edge that connects a vertex to itself is called a loop and multiple edges between the same pair of
vertex are called parallel edges. Graphs without loops and parallel edges are called simple graphs,
otherwise they are called multigraphs.
Some graphs also assign directions to edges. These are known as directed graphs.
Unless specified otherwise, we will only deal with simple, undirected graphs.
Proof: Prove that the sum of degrees of all nodes in a graph is twice the number of edges.
Solution 1: Since each edge is incident to exactly two vertices, each edge contributes two to the
sum of degrees of the vertices. The claim follows.
Solution 2: We can also prove the claim using induction on the number of edges. Let us
reformulate the claim in a way that makes clear all of the parameters in the problem. We are
trying to prove the claim that in a graph G with n vertices and m edges, that:
X
deg(v) = 2|E|
v∈V
Base Case: m = 0
Let G be an arbitrary graph with n vertices and 0 edges. Note that the degree of each vertex in
the graph must be 0, since there are no edges. Thus, the sum of the degree of all of the vertices
must also be 0.
Lecture 20 CMSC 250 2
Induction Hypothesis:
Assume that, for some k ∈ N, an arbitrary graph with n vertices and k edges has the following
property: X
deg(v) = 2|E|
v∈V
Induction Step:
Let G(V, E) be an arbitrary graph with n vertices and k + 1 edges. Consider the graph G0 (V 0 , E 0 )
that is the graph constructed by removing an arbitrary edge e = {u, v} from G. Note that G0 is a
graph with n vertices and k edges. By the Induction Hypothesis, we know that:
X
deg(v) = 2|E 0 |
v∈V 0
Let us consider what happens when we add e back. Note that the addition of e increases the degree
of u by 1 and the degree of v by 1, and does not affect the degree of any other vertex. So, we know
that the sum of the degrees of all of the vertices should increase by 2.
Hence, we have that:
X X
deg(v) = deg(v) + 2
v∈V v∈V 0
deg(v) = 2|E 0 |:
P
By the Induction Hypothesis, we have that v∈V 0
= 2|E 0 | + 2
= 2(|E 0 | + 1)
But we know that |E 0 | = |E| − 1 since we removed one edge from G to construct G0 :
= 2(|E| − 1 + 1)
= 2|E|
Problem:
Prove that, in any graph, there are an even number of vertices of odd degree.
Solution:
Let Ve and Vo be the set of vertices with even degree and the set of vertices with odd degree
respectively in a graph G = (V, E). Then,
X X X
deg(v) = deg(v) + deg(v)
v∈V v∈Ve v∈Vo
The first term on R.H.S. is even since each vertex in Ve has an even degree. From the previous
example, we know that L.H.S. of the above equation is even. Thus, the second term on the R.H.S.
Lecture 20 CMSC 250 3
must be even. Since each vertex in Vo has odd degree, for the sum of the degrees of vertices in Vo
to be even, |Vo | must be even. This proves the claim.
Problem:
Prove that a graph with n vertices and m edges has at least n − m connected components.
Solution:
We will prove this claim by doing induction on m.
Base Case: m = 0
A graph with n vertices and no edges has n connected components as each vertex itself is a connected
component. So the graph has at least n − 0 connected components as required. Hence the claim is
true for m = 0.
Induction Hypothesis:
Assume that, for some k ≥ 0, every graph with n vertices and k edges has at least n − k connected
components.
Induction Step:
We want to prove that a graph, G, with n vertices and k +1 edges has at least n−(k +1) = n−k −1
connected components. Let G be an arbitrary graph with n vertices and k + 1 edges.
Lecture 20 CMSC 250 4
Consider a graph G0 constructed by removing an arbitrary edge {u, v} from G. The graph G0 has n
vertices and k edges. By Induction Hypothesis, G0 has at least n − k connected components. Now
consider what happens when we add {u, v} to G0 to obtain the graph G. We consider the following
two cases:
Case I: u and v belong to the same connected component in G0
In this case, adding the edge {u, v} to G0 is not going to change any connected components of
G0 . Hence, in this case the number of connected components of G is the same as the number of
connected components of G0 which is at least n − k > n − k − 1.
Case II: u and v belong to different connected components of G0
In this case, the two connected components containing u and v become one connected component
in G. All other connected components in G0 remain unchanged. Thus, G has one less connected
component than G0 . Hence, G has at least n − k − 1 connected components.