0% found this document useful (0 votes)
197 views88 pages

11 Graph Theory

fdaf

Uploaded by

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

11 Graph Theory

fdaf

Uploaded by

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

Graph Theory

Copyright Cengage Learning. All rights reserved.

Graphs: Definitions and Basic


Properties
The edges may be straight or curved and should
either connect one vertex to another or a vertex to
itself, as shown below.

Graphs: Definitions and Basic


Properties
In this drawing, the vertices have been labeled with v s and
the edges with es.
When an edge connects a vertex to itself (as e5 does), it is
called a loop. When two edges connect the same pair of
vertices (as e2 and e3 do), they are said to be parallel.
It is quite possible for a vertex to be unconnected by an
edge to any other vertex in the graph (as v5 is), and in that
case the vertex is said to be isolated.

Graphs: Definitions and Basic


Properties
The formal definition of a graph follows.

Graphs: Definitions and Basic


Properties
Graphs have pictorial representations in which the vertices
are represented by dots and the edges by line segments.
A given pictorial representation uniquely determines a
graph.

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

Graphs: Definitions and Basic


Properties
As noted earlier, a given pictorial representation uniquely
determines a graph.
However, a given graph may have more than one pictorial
representation.
Such things as the lengths or curvatures of the edges and
the relative position of the vertices on the page may vary
from one pictorial representation to another.

Graphs: Definitions and Basic


Properties
We have discussed the directed graph of a binary relation
on a set.
The general definition of directed graph is similar to the
definition of graph, except that one associates an ordered
pair of vertices with each edge instead of a set of vertices.
Thus each edge of a directed graph can be drawn as an
arrow going from the first vertex to the second vertex of the
ordered pair.

Graphs: Definitions and Basic


Properties

Note that each directed graph has an associated


ordinary (undirected) graph, which is obtained by
ignoring the directions of the edges.

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.

Example Using a Graph to Represent a


Network

A typical network, called a hub and


spoke model, is shown below.

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 A Simple Graph


Draw all simple graphs with the four vertices {u,
v, w, x} and two edges, one of which is {u, v}.
Solution:
Each possible edge of a simple graph
corresponds to a subset of two vertices.
Given four vertices, there are
= 6 such
subsets in all:
{u, v}, {u, w}, {u, x}, {v, w}, {v, x}, and {w,
x}.

Example Solution

contd

Now one edge of the graph is specified


to be {u, v}, so any of the remaining
five from this list can be chosen to be
the second edge.
The possibilities are shown below.

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.

Example Complete Graphs on n Vertices: K1, K2, K3, K4,


K5

The complete graphs K1, K2, K3, K4, and


K5 can be drawn as follows:

Special Graphs

The Concept of Degree


The degree of a vertex is the number of end segments of
edges that stick out of the vertex.
We will show that the sum of the degrees of all the vertices
in a graph is twice the number of edges of the graph.

The Concept of Degree


Since an edge that is a loop is counted twice, the degree of
a vertex can be obtained from the drawing of a graph by
counting how many end segments of edges are incident on
the vertex.
This is illustrated below.

Example Degree of a Vertex and Total Degree of a


Graph

Find the degree of each vertex of the


graph G shown below. Then find the
total degree of G.

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.

The Concept of Degree


Note that the total degree of the graph G, which is
6, equals twice the number of edges of G, which is
3.
Roughly speaking, this is true because each edge
has two end segments, and each end segment is
counted once toward the degree of some vertex.
This result generalizes to any graph.
In fact, for any graph without loops, the general
result can be explained as follows: Imagine a group
of people at a party. Depending on how social they
are, each person shakes hands with various other
people.

The Concept of Degree


As the proof demonstrates, the conclusion is true even if
the graph contains loops.

The Concept of Degree


The following proposition is easily deduced from
Corollary 10.1.2 using properties of even and odd
integers.

Trails, Paths, and Circuits


The subject of graph theory began in the year
1736 when the great mathematician Leonhard
Euler published a paper giving the solution to the
following puzzle:
The town of Knigsberg in Prussia (now Kaliningrad
in Russia) was built at a point where two branches
of the Pregel River came together.
It consisted of an island and some land along the
river banks.

Trails, Paths, and Circuits


These were connected by seven
bridges as shown in
Figure 10.2.1.

The Seven Bridges of Knigsberg


Figure 10.2.1

Trails, Paths, and Circuits


Thus for the purpose of solving the puzzle, the map
of Knigsberg can be identified with the graph
shown in Figure 10.2.2, in which the vertices A, B, C,
and D represent land masses and the seven edges
represent the seven bridges.

Graph Version of Knigsberg Map


Figure 10.2.2

Trails, Paths, and Circuits


In terms of this graph, the question becomes the following:
Is it possible to find a route through the graph that starts
and ends at some vertex, one of A, B, C, or D, and
traverses each edge exactly once?
Equivalently:
Is it possible to trace this graph, starting and ending at
the same point, without ever lifting your pencil from the
paper?

Trails, Paths, and Circuits


So, if it is possible to find a route that uses all the
edges of the graph and starts and ends at A, then
the total number of arrivals and departures from
each vertex B, C, and D must be a multiple of 2.
Or, in other words, the degrees of the vertices B,
C, and D must be even.
But they are not: deg(B) = 5, deg(C) = 3, and
deg(D) = 3. Hence there is no route that solves
the puzzle by starting and ending at A.

Trails, Paths, and Circuits


Similar reasoning can be used to show
that there are no routes that solve the
puzzle by starting and ending at B, C,
or D.
Therefore, it is impossible to travel all
around the city crossing each bridge
exactly once.

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

Certain types of sequences of adjacent


vertices and edges are of special
importance in graph theory: those that do
not have a repeated edge, those that do
not have a repeated vertex, and those that
start and end at the same vertex.

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.

If you take the negation of this definition, you will


see that a graph G is not connected if, and only if,
there are two vertices of G that are not connected
by any walk.

Example Connected and Disconnected


Graphs

Which of the following graphs are


connected?

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:

This version of Theorem 10.2.2 is useful for showing


that a given graph does not have an Euler circuit.

Example Showing That a Graph Does Not Have an Euler


Circuit

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 Finding an Euler


Trail
The floor plan shown below is for a house that is
open for public viewing. Is it possible to find a trail
that starts in room A, ends in room B, and passes
through every interior doorway of the house exactly
once? If so, find such a trail.

Example Solution
Let the floor plan of the house be represented by the
graph below.

Each vertex of this graph has even degree except for A


and B, each of which has degree 1.
Hence by Corollary 10.2.5, there is an Euler path from A
to B. One such trail is
AGHFEIHEKJDCB.

Hamiltonian Circuits
Theorem 10.2.4 completely answers the following
question:

Given a graph G, is it possible to find a circuit for G in


which all the edges of G appear exactly once?
A related question is this: Given a graph G, is it possible
to find a circuit for G in which all the vertices of G (except
the first and the last) appear exactly once?

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.

Unfortunately, there is no analogous


criterion for determining whether a given
graph has a Hamiltonian circuit, nor is
there even an efficient algorithm for
finding such a 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.

Note that H has the same number of edges as it has vertices


since all its n edges are distinct and so are its n vertices v1,
v2, . . . , vn.
Also, by definition of Hamiltonian circuit, every vertex of G is
a vertex of H, and H is connected since any two of its vertices
lie on a circuit. In addition, every vertex of H has degree 2.

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 A Traveling Salesman


Problem
Imagine that the drawing below is a map showing
four cities and the distances in kilometers between
them.
Suppose that a salesman must travel to each city
exactly once, starting and ending in city A. Which
route from city to city will minimize the total
distance that must be traveled?

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.

Thus either route ABCDA or ADCBA gives a


minimum total distance of 125 kilometers.

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

Observe that G is a different graph from G (for


instance, in G the endpoints of e1 are v1 and v2,
whereas in G the endpoints of e1 are v1 and v3).

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

Note that these relabeling functions are one-to-one and onto.

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.

Example Showing That Two Graphs Are


Isomorphic
Show that the following two graphs are isomorphic.

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

Setting up such functions is partly a matter of trial and


error and partly a matter of deduction.
For instance, since e2 and e3 are parallel (have the
same endpoints), h(e2) and h(e3) must be parallel also.
So h(e2) = f1 and h(e3) = f2 or h(e2) = f2 and h(e3) = f1.
Also, the endpoints of e2 and e3 must correspond to the
endpoints of f1 and f2, and so g(v3) = w1 and g(v4) = w5
or g(v3) = w5 and g(v4) = w1.

Example Solution

contd

Similarly, since v1 is the endpoint of four distinct edges


(e1, e7, e5, and e4), g(v1) must also be the endpoint of
four distinct edges (because every edge incident on
g(v1) is the image under h of an edge incident on v1 and
h is
one-to-one and onto).
But the only vertex in G that has four edges coming out
of it is w2, and so g(v1) = w2.
Now if g(v3) = w1, then since v1 and v3 are endpoints of
e1 in G, g(v1) = w2 and g(v3) = w1 must be endpoints of
h(e1) in G. This implies that h(e1) = f3.

Example Solution

contd

By continuing in this way, possibly making some


arbitrary choices as you go, you eventually can find
functions g and h to define the isomorphism
between G and G.
One pair of functions (there are several) is the
following:

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.

Now consider the question, Is there a general method to


figure out whether graphs G and G are isomorphic?
In other words, is there some algorithm that will accept
graphs G and G as input and produce a statement as to
whether they are isomorphic?

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

Example Showing That Two Graph Are Not


Isomorphic

Show that the following pairs of graphs are


not isomorphic by finding an isomorphic
invariant that they do not share.
a.

b.

Example Solution
a. G has nine edges; G has only eight.
b. H has a vertex of degree 4; H does
not.

Graph Isomorphism for Simple


Graphs
When graphs G and G are both simple, the
definition of G being isomorphic to G can be
written without referring to the
correspondence between the edges of G and
the edges of G.

Example Isomorphism of Simple


Graphs
Are the two graphs shown below
isomorphic? If so, define an
isomorphism.

Example Solution
Yes. Define f : V(G) V(G) by the arrow
diagram shown below.

Then g is one-to-one and onto by inspection.

Example Solution
The fact that g preserves the edgeendpoint functions of G and G is
shown by the following table:

contd

You might also like