11 Graph Theory
11 Graph Theory
Example Terminology
Consider the following graph:
a. Write the vertex set and the edge set, and give a table
showing the edge-endpoint function.
b. Find all edges that are incident on v1, all vertices that
are adjacent to v1, all edges that are adjacent to e1, all
loops, all parallel edges, all vertices that are adjacent to
themselves, and all isolated vertices.
Example a Solution
vertex set = {v1, v2, v3, v4, v5, v6}
edge set = {e1, e2, e3, e4, e5, e6, e7}
edge-endpoint function:
Example b Solution
e1, e2, and e3 are incident on v1.
v2 and v3 are adjacent to v1.
e2, e3, and e4 are adjacent to e1.
e6 and e7 are loops.
e2 and e3 are parallel.
v5 and v6 are adjacent to themselves.
v4 is an isolated vertex.
contd
Examples of Graphs
Graphs are a powerful problem-solving tool because
they enable us to represent a complex situation
with a single image that can be analyzed both
visually and with the aid of a computer.
contd
Special Graphs
One important class of graphs consists of those that
do not have any loops or parallel edges.
Such graphs are called simple. In a simple graph, no
two edges share the same set of endpoints, so
specifying two endpoints is sufficient to determine
an edge.
Example Solution
contd
Special Graphs
Another important class of graphs consists of those
that are complete in the sense that all pairs of
vertices are connected by edges.
Special Graphs
Example Solution
deg(v1) = 0 since no edge is incident on v1 (v1 is isolated).
deg(v2) = 2 since both e1 and e2 are incident on v2.
deg(v3) = 4 since e1 and e2 are incident on v3 and the loop
e3 is also incident on v3 (and contributes 2 to the degree of
v3).
total degree of G = deg(v1) + deg(v2) + deg(v3)
=0+2+4
= 6.
Definitions
Travel in a graph is accomplished by moving from
one vertex to another along a sequence of adjacent
edges.
In the graph below, for instance, you can go from u1
to u4 by taking f1 to u2 and then f7 to u4. This is
represented by writing u1f1u2f7u4.
Definitions
Or you could take the roundabout route
Definitions
Connectedness
It is easy to understand the concept of
connectedness on an intuitive level.
Roughly speaking, a graph is
connected if it is possible to travel
from any vertex to any other vertex
along a sequence of adjacent edges of
the graph.
Connectedness
The formal definition of connectedness is stated in
terms of walks.
Example Solution
The graph represented in (a) is connected, whereas
those of (b) and (c) are not. To understand why (c)
is not connected, we know that in a drawing of a
graph, two edges may cross at a point that is not a
vertex.
Thus the graph in (c) can be redrawn as follows:
Connectedness
Some useful facts relating circuits and
connectedness are collected in the
following lemma.
Euler Circuits
Now we return to consider general
problems similar to the puzzle of the
Knigsberg bridges.
The following definition is made in
honor of Euler.
Euler Circuits
The analysis used earlier to solve the
puzzle of the Knigsberg bridges
generalizes to prove the following
theorem:
Euler Circuits
We know that the contrapositive of a statement is
logically equivalent to the statement.
The contrapositive of Theorem 10.2.2 is as follows:
Show that the graph below does not have an Euler circuit.
Solution:
Vertices v1 and v3 both have degree 3, which is odd.
Hence by (the contrapositive form of) Theorem 10.2.2,
this graph does not have an Euler circuit.
Euler Circuits
Now consider the converse of Theorem 10.2.2: If
every vertex of a graph has even degree, then the
graph has an Euler circuit. Is this true?
The answer is no. There is a graph G such that
every vertex of G has even degree but G does not
have an Euler circuit. In fact, there are many such
graphs. The illustration below shows one example.
Euler Circuits
Note that the graph in the preceding drawing is not
connected.
It turns out that although the converse of Theorem
10.2.2 is false, a modified converse is true: If every
vertex of a graph has positive even degree and if
the graph is connected, then the graph has an Euler
circuit.
Euler Circuits
The proof of this fact is constructive: It
contains an algorithm to find an Euler
circuit for any connected graph in
which every vertex has even degree.
Euler Circuits
A corollary to Theorem 10.2.4 gives a criterion for
determining when it is possible to find a walk from
one vertex of a graph to another, passing through
every vertex of the graph at least once and every
edge of the graph exactly once.
Example Solution
Let the floor plan of the house be represented by the
graph below.
Hamiltonian Circuits
Theorem 10.2.4 completely answers the following
question:
Hamiltonian Circuits
In 1859 the Irish mathematician Sir William
Rowan Hamilton introduced a puzzle in the
shape of a dodecahedron
(DOH-dek-a-HEE-dron). (Figure 10.2.6
contains a drawing of a dodecahedron, which
is a solid figure with 12 identical pentagonal
faces.)
Dodecahedron
Figure 10.2.6
Hamiltonian Circuits
Each vertex was labeled with the name of a city
London, Paris, Hong Kong, New York, and so on.
The problem Hamilton posed was to start at one city and
tour the world by visiting each other city exactly once
and returning to the starting city.
One way to solve the puzzle is to imagine the surface of
the dodecahedron stretched out and laid flat in the
plane, as follows:
Hamiltonian Circuits
The circuit denoted with black lines is one
solution. Note that although every city is
visited, many edges are omitted from the
circuit. (More difficult versions of the puzzle
required that certain cities be visited in a
certain order.)
The following definition is made in honor of
Hamilton.
Hamiltonian Circuits
Note that although an Euler circuit for a graph G must
include every vertex of G, it may visit some vertices
more than once and hence may not be a Hamiltonian
circuit.
On the other hand, a Hamiltonian circuit for G does not
need to include all the edges of G and hence may not
be an Euler circuit.
Despite the analogous-sounding definitions of Euler
and Hamiltonian circuits, the mathematics of the two
are very different.
Hamiltonian Circuits
Theorem 10.2.4 gives a simple criterion for
determining whether a given graph has an
Euler circuit.
Hamiltonian Circuits
There is, however, a simple technique that can be used in
many cases to show that a graph does not have a
Hamiltonian circuit.
This follows from the following considerations:
Suppose a graph G with at least two vertices has a
Hamiltonian circuit C given concretely as
Since C is a simple circuit, all the ei are distinct and all the
vj are distinct except that v0 = vn. Let H be the subgraph
of G that is formed using the vertices and edges of C.
Hamiltonian Circuits
An example of such an H is shown below.
Hamiltonian Circuits
The reason for this is that there are
exactly two edges incident on any
vertex. These are ei and ei+1 for any
vertex vi except v0 = vn, and they are
e1 and en for v0 (= vn).
These observations have established
the truth of the following proposition in
all cases where G has at least two
vertices.
Hamiltonian Circuits
We know that the contrapositive of a statement is
logically
equivalent to the statement.
The contrapositive of Proposition 10.2.6 says that if a
graph G does not have a subgraph H with properties
(1)(4), then G does not have a Hamiltonian circuit.
The next example illustrates a type of problem known
as a traveling salesman problem. It is a variation of
the problem of finding a Hamiltonian circuit for a
graph.
Example Solution
This problem can be solved by writing all possible
Hamiltonian circuits starting and ending at A and
calculating the total distance traveled for each.
Hamiltonian Circuits
The general traveling salesman problem involves
finding a Hamiltonian circuit to minimize the total
distance traveled for an arbitrary graph with n
vertices in which each edge is marked with a
distance.
One way to solve the general problem is to write
down all Hamiltonian circuits starting and ending
at a particular vertex, compute the total distance
for each, and pick one for which this total is
minimal.
Hamiltonian Circuits
However, even for medium-sized values of n this
method is impractical.
For a complete graph with 30 vertices, there would be
Hamiltonian circuits starting and
ending at a particular vertex to check.
Even if each circuit could be found and its total
distance computed in just one nanosecond, it would
require approximately 1.4 1014 years to finish the
computation.
Hamiltonian Circuits
At present, there is no known algorithm for
solving the general traveling salesman
problem that is more efficient.
However, there are efficient algorithms that
find pretty good solutionsthat is, circuits
that, while not necessarily having the least
possible total distances, have smaller total
distances than most other Hamiltonian
circuits.
Isomorphisms of Graphs
The two drawings shown in Figure
10.4.1 both represent the same graph:
Their vertex and edge sets are
identical, and their edge-endpoint
functions are the same. Call this graph
G.
Figure 10.4.1
Isomorphisms of Graphs
Now consider the graph G represented in Figure 10.4.2.
Figure 10.4.2
Isomorphisms of Graphs
Yet G is certainly very similar to G. In fact, if the vertices and
edges of G are relabeled by the functions shown in Figure
10.4.3, then G becomes the same as G.
Figure 10.4.3
Isomorphisms of Graphs
Two graphs that are the same except for the
labeling of their vertices and edges are called
isomorphic.
The word isomorphism comes from the Greek,
meaning same form. Isomorphic graphs are those
that have essentially the same form.
Isomorphisms of Graphs
In words, G is isomorphic to G if, and only if, the
vertices and edges of G and G can be matched up by
one-to-one, onto functions such that the edges between
corresponding vertices correspond to each other.
It is common in mathematics to identify objects that are
isomorphic.
For instance, if we are given a graph G with five vertices
such that each pair of vertices is connected by an edge,
then we may identify G with K5, saying that G is K5
rather than that G is isomorphic to K5.
G'
Solution:
To solve this problem, you must find functions g: V(G) V(G)
and h: E(G) E(G) such that for all v V(G) and e E(G), v
is an endpoint of e if, and only if, g(v) is an endpoint of h(e).
Example Solution
contd
Example Solution
contd
Example Solution
contd
Isomorphisms of Graphs
It is not hard to show that graph isomorphism is an
equivalence relation on a set of graphs; in other words, it
is reflexive, symmetric, and transitive.
Isomorphisms of Graphs
In fact, there is such an algorithm. It consists of
generating all one-to-one, onto functions from
the set of vertices of G to the set of vertices of G
and from the set of edges of G to the set of
edges of G and checking each pair to determine
whether it preserves the edge-endpoint functions
of G and G.
The problem with this algorithm is that it takes
an unreasonably long time to perform, even on a
high-speed computer.
Isomorphisms of Graphs
If G and G each have n vertices and m edges, the
number of one-to-one correspondences from vertices
to vertices is n! and the number of one-to-one
correspondences from edges to edges is m!, so the
total number of pairs of functions to check is n! m!.
For instance, if m = n = 20, there would be
20! 20! 5.9 1036 pairs to check.
Assuming that each check takes just 1 nanosecond,
the total time would be approximately 1.9 1020 years!
Isomorphisms of Graphs
Unfortunately, there is no more efficient general method
known for checking whether two graphs are isomorphic.
However, there are some simple tests that can be used to
show that certain pairs of graphs are not isomorphic.
For instance, if two graphs are isomorphic, then they have
the same number of vertices (because there is a one-toone correspondence from the vertex set of one graph to
the vertex set of the other).
It follows that if you are given two graphs, one with 16
vertices and the other with 17, you can immediately
conclude that the two are not isomorphic.
Isomorphisms of Graphs
More generally, a property that is preserved by
graph isomorphism is called an isomorphic
invariant.
For instance, having 16 vertices is an isomorphic
invariant: If one graph has 16 vertices, then so does
any graph that is isomorphic to it.
Isomorphisms of Graphs
b.
Example Solution
a. G has nine edges; G has only eight.
b. H has a vertex of degree 4; H does
not.
Example Solution
Yes. Define f : V(G) V(G) by the arrow
diagram shown below.
Example Solution
The fact that g preserves the edgeendpoint functions of G and G is
shown by the following table:
contd