Cha5 Graph Theory
Cha5 Graph Theory
Cha5 Graph Theory
Graph Theory
Graphs, directed graphs, trees and binary trees appear in many areas of mathematics
and computer science. In order to understand how these objects may be stored in
memory and to understand algorithms on them, we need to know a little about
certain data structures.
We denote such a graph by G(V, E)1 when we want to emphasize the two parts of
G.
Vertices u and v are said to be adjacent or neighbors if there is an edge e = {u, v}.
In such a case, u and v are called the endpoints of e, and e is said to connect u
and v. Also, the edge e is said to be incident on each of its endpoints u and v.
Graphs are pictured by diagrams in the plane in a natural way. Specifically, each
vertex v in V is represented by a dot (or small circle), and each edge e = {v1 , v2 }
is represented by a curve which connects its endpoints v1 and v2 .
lbbel=() The representation of a binary relation defined on a given set. The relation of a
given element x to another element y is represented with an arrow connecting x
to y.
59
60 CHAPTER 5. GRAPH THEORY
a b
d c
If the graph is directed and there is a unique edge e pointing from x to y, then we
may write e = (x, y), so E may be regarded as a set of ordered pairs. If e = (x, y),
the vertex x is called origin, source or initial point of the edge e, and y is called the
terminus, terminating vertex or terminal point.
a b
d c
Two vertices connected by an edge are called adjacent. They are also the
endpoints of the edge, and the edge is said to be incident to each of its endpoints.
If the graph is directed, an edge pointing from vertex x to vertex y is said to be
incident from x and incident to y. An edge connecting a vertex to itself is called
1. GRAPHS AND MULTIGRAPHS 61
a loop. Two edges connecting the same pair of points (and pointing in the same
direction if the graph is directed) are called parallel or multiple.
A graph with neither loops nor multiple edges is called a simple graph. If a
graph has multiple edges but no loops then it is called a multigraph. If it has loops
(and possible also multiple edges) then it is called a pseudograph.
The following table summarizes the graph terminology
The degree of a vertex v, represented deg(v), is the number of edges that contain
it (loops are counted twice). A vertex of degree zero (not connected to any other
vertex) is called isolated. A vertex of degree 1 is called pendant.
Since deg(v) is even for v ∈ Ve , the first sum in the right hand side of the
equality is even. The total sum must be 2e, which is even, so the second sum must
be even too. But its terms are all odd, so there must be an even number of them.
Sum of degrees in an directed graph: Let G = (V, E) be a directed graph.
Then
∑ ∑
deg(v) = deg+ (v) = |E|
v∈V v∈V
62 CHAPTER 5. GRAPH THEORY
A weighted graph is a graph whose edges have been labeled with numbers. The
length of a path in a weighted graph is the sum of the weights of the edges in the
path.
a b
6 3
7
d c
4
010
011
100
101
000 001
Complete Graph: a simple undirected graph G such that every pair of distinct
vertices in G are connected by an edge. The complete graph of n vertices is
represented by Kn (see figure ??). A complete directed graph is a simple directed
graph G = (V, E) such that every pair of distinct vertices in G are connected by
exactly one edge — so, for each pair of distinct vertices, either (x, y) or (y, x) (but
not both) is in E.
a
e b
d c
A graph is bipartite iff its vertices can be colored with two colors so that every
edge connects vertices of different color.
Question: Is the n-cube bipartite. Hint: color in red all vertices whose binary
representation has an even number of 1’s, color in blue the ones with an odd number
of 1’s.
p
a
q
b
r
c
s
Regular Graph: a simple graph whose vertices have all the same degree. For
instance, the n-cube is regular.
1.2 Subgraph
Given a graph G = (V, E), a subgraph G′ = (V ′ , E ′ ) of G is another graph such
that V ′ ⊆ V and E ′ ⊆ E. If V ′ = V then G′ is called a spanning subgraph of G.
2 Representations of Graphs
2.1 Adjacency matrix
The adjacency matrix of a graph is a matrix with rows and columns labeled by the
vertices and such that its entry in row i, column j, i ̸= j, is the number of edges
incident on i and j. For instance the following is the adjacency matrix of the graph
of figure ??:2
2
For some authors, if i = j then the entry is twice the number of loops incident on i; so in the
example of figure ?? entry (a, b) and (b, a), etc., would be 2 instead of 1.
64 CHAPTER 5. GRAPH THEORY
a b c d e f
a 0 2 1 1 2 0
b 2 0 1 0 0 1
c 1 1 0 1 0 0
d
1 0 1 0 1 0
e
2 0 0 1 0 1
f 0 1 0 0 1 1
e5
e6 e2 e8
e1
e7
e3
e4
e10
e9
e12 e11
a1 b1
e1 c1
d1
Remark: Two graphs are isomorphic if and only if for some ordering of their
vertices their adjacency matrices are equal.
An invariant is a property such that if a graph has it then all graphs isomorphic
to it also have it. Examples of invariants are their number of vertices, their number
of edges, “has a vertex of degree k”, “has a simple cycle of length l”, etc. It
is possible to prove that two graphs are not isomorphic by showing an invariant
property that one has and the other one does not have. For instance the graphs in
figure ?? cannot be isomorphic because one has a vertex of degree 2 and the other
one doesn’t.
66 CHAPTER 5. GRAPH THEORY
During the eighteenth century the city of Konigsberg (in East Prussia)3 was
divided into four sections, including the island of Kneiphop, by the Pregel river.
Seven bridges connected the regions, as shown in figure ??. It was said that residents
spent their Sunday walks trying to find a way to walk about the city so as to cross
each bridge exactly once and then return to the starting point. The first person to
solve the problem (in the negative) was the Swiss mathematician Leonhard Euler
in 1736. He represented the sections of the city and the seven bridges by the graph
3
The city is currently called Kaliningrad and is part of the Russian republic.
3. PATHS AND CIRCUITS 67
of figure 7.12, and proved that it is impossible to find a path in it that transverses
every edge of the graph exactly once. In the next section we study why this is so.
have a Hamilton circuit if |V 1| ̸= |V 2|, because any path must contain alternatively
vertices from V1 and V2, so any circuit in G must have the same number of vertices
from each of both sets.
Edge removal argument: Another kind of argument consists of re- moving edges
trying to make the degree of every vertex equal two. For instance in the graph of
figure 7.14 we cannot remove any edge because that would make the degree of b, e
or d less than 2, so it is impossible to reduce the degree of a and c. Consequently
that graph has no Hamilton circuit.
Dirac’s Theorem: If G is a simple graph with n vertices with n ≥ 3 such that
the degree of every vertex in G is at least n/2, then G has a Hamilton circuit.
Ore’s Theorem: If G is a simple graph with n vertices with n � 3 such that
deg(u) + deg(v) ≥ n for every pair of nonadjacent vertices u and v in G, then G
has a Hamilton circuit.