Chapter 10
Chapter 10
Chapter 10
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill
Chapter Summary
Graphs and Graph Models
Graph Terminology and Special Types of Graphs
Representing Graphs and Graph Isomorphism
Connectivity
Euler and Hamiltonian Graphs
Shortest-Path Problems (not currently included in
overheads)
Planar Graphs (not currently included in
overheads)
Graph Coloring (not currently included in
overheads)
Graphs and Graph
Models
Section 10.1
Section Summary
Introduction to Graphs
Graph Taxonomy
Graph Models
Graphs
Definition: A graph G = (V, E) consists of a nonempty set V of vertices
(or nodes) and a set E of edges. Each edge has either one or two vertices
associated with it, called its endpoints. An edge is said to connect its
endpoints.
Exampl a b
e: is a
This
graph with
four vertices
and five
edges.
d c
Remarks:
The graphs we study here are unrelated to graphs of functions studied in Chapter 2.
We have a lot of freedom when we draw a picture of a graph. All that matters is the connections made
by the edges, not the particular geometry depicted. For example, the lengths of edges, whether edges
cross, how vertices are depicted, and so on, do not matter
A graph with an infinite vertex set is called an infinite graph. A graph with a finite vertex set is called a
finite graph. We (following the text) restrict our attention to finite graphs.
Some Terminology
In a simple graph each edge connects two different vertices
and no two edges connect the same pair of vertices.
Multigraphs may have multiple edges connecting the same
two vertices. When m different edges connect the vertices u
and v, we say that {u,v} is an edge of multiplicity m.
An edge that connects a vertex to itself is called a loop.
A pseudograph may include loops, as well as multiple edges
connecting the same pair of vertices.
a b
Exampl
e:
This is a directed graph
with three vertices and
A directed multigraph may have multiple directed edges.
four edges. c
When there are m directed edges from the vertex u to the
vertex v, we say that (u,v) is an edge of multiplicity m.
Exampl
e: a b
In this directed multigraph the
multiplicity of (a,b) is 1 and the
multiplicity of (b,c) is 2.
c
Graph Models: Computer Networks
When we build a graph model, we use the appropriate type
of graph to capture the important features of the
application.
We illustrate this process using graph models of different
types of computer networks. In all these graph models, the
vertices represent data centers and the edges represent
communication links.
To model a computer network where we are only concerned
whether two data centers are connected by a
communications link, we use a simple graph. This is the
appropriate type of graph when we only care whether two
data centers are directly linked (and not how many links
there may be) and all communications links work in both
directions.
Graph Models: Computer Networks
(continued)
To model a computer
network where we care
about the number of links
between data centers, we
use a multigraph.
To model a computer
network with diagnostic
links at data centers, we
use a pseudograph, as
loops are needed.
To model a network with multiple
one-way links, we use a directed
multigraph. Note that we could
use a directed graph without
multiple edges if we only care
whether there is at least one link
from a data center to another data
Graph Terminology: Summary
To understand the structure of a graph and to build
a graph model, we ask these questions:
Are the edges of the graph undirected or directed (or
both)?
If the edges are undirected, are multiple edges
present that connect the same pair of vertices? If the
edges are directed, are multiple directed edges
present?
Are loops present?
Other Applications of Graphs
We will illustrate how graph theory can be used in
models of:
Social networks
Communications networks
Information networks
Software design
Transportation networks
Biological networks
It’s a challenge to find a subject to which graph
theory has not yet been applied. Can you find an
area without applications of graph theory?
Graph Models: Social Networks
Graphs can be used to model social structures based on
different kinds of relationships between people or groups.
In a social network, vertices represent individuals or
organizations and edges represent relationships between
them.
Useful graph models of social networks include:
friendship graphs - undirected graphs where two people
are connected if they are friends (in the real world, on
Facebook, or in a particular virtual world, and so on.)
collaboration graphs - undirected graphs where two
people are connected if they collaborate in a specific way
influence graphs - directed graphs where there is an edge
from one person to another if the first person can
influence the second person
Graph Models: Social Networks
(continued)
Example: A
friendship graph
where two people are
connected if they are
Facebook friends.
Example: An
influence
graph
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}.
Degrees of Vertices
Theorem 1 (Handshaking Theorem): If G = (V,E) is an
undirected graph with m edges, then

Proof:
Each edge contributes twice to the degree count of all
vertices. Hence, both the left-hand and right-hand sides of
this equation equal twice the number of edges.
Some local area networks use a star topology, which is a complete bipartite
graph K1,n ,as shown in (a). All devices are connected to a central control device.
Other local networks are based on a ring topology, where each device is
connected to exactly two others using Cn ,as illustrated in (b). Messages may be
sent around the ring.
Others, as illustrated in (c), use a Wn – based topology, combining the features
of a star topology and a ring topology.
Various special graphs also play a role in parallel processing where processors
need to be interconnected as one processor may need the output generated by
another.
The n-dimensional hypercube, or n-cube, Qn, is a common way to connect
processors in parallel, e.g., Intel Hypercube.
Another common method is the mesh network, illustrated here
for 16 processors.
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.
Example:
Representing Graphs
and Graph Isomorphism
Section 10.3
Section Summary
Adjacency Lists
Adjacency Matrices
Incidence Matrices
Isomorphism of Graphs
Representing Graphs: Adjacency
Lists
Definition: An adjacency list can be used to
represent a graph with no multiple edges by
specifying the vertices that are adjacent to each
vertex of the graph.
Example:
Example:
Representation of Graphs:
Adjacency Matrices
Definition: Suppose that G = (V, E) is a simple
graph where |V| = n. Arbitrarily list the vertices
of G as v1, v2, … , vn. The adjacency
matrix AG of G, with respect to the listing of
vertices, is the n × n zero-one matrix with 1 as
its (i, j)th entry when vi and vj are adjacent, and
0 as its (i, j)th entry when they are not adjacent.
The function f with f(u1) = v6, f(u2) = v3, f(u3) = v4, and f(u4) = v5 , f(u5) = v1, and
f(u6) = v2 is a one-to-one correspondence between G and H. Showing that this
correspondence preserves edges is straightforward, so we will omit the details
here. Because f is an isomorphism, it follows that G and H are isomorphic
graphs.
See the text for an illustration of how adjacency matrices can be used for this
verification.
Algorithms for Graph Isomorphism
The best algorithms known for determining whether
two graphs are isomorphic have exponential worst-
case time complexity (in the number of vertices of
the graphs).
However, there are algorithms with linear average-
case time complexity.
You can use a public domain program called NAUTY
to determine in less than a second whether two
graphs with as many as 100 vertices are isomoprhic.
Graph isomorphism is a problem of special interest
because it is one of a few NP problems not known to
be either tractable or NP-complete (see Section 3.3).
Applications of Graph Isomorphism
The question whether graphs are isomorphic plays an
important role in applications of graph theory. For
example,
chemists use molecular graphs to model chemical
compounds. Vertices represent atoms and edges represent
chemical bonds. When a new compound is synthesized, a
database of molecular graphs is checked to determine
whether the graph representing the new compound is
isomorphic to the graph of a compound that this already
known.
Electronic circuits are modeled as graphs in which the
vertices represent components and the edges represent
connections between them. Graph isomorphism is the
basis for
the verification that a particular layout of a circuit
corresponds to the design’s original schematics.
determining whether a chip from one vendor includes
the intellectual property of another vendor.
Connectivity
Section 10.4
Section Summary
Paths
Connectedness in Undirected Graphs
Vertex Connectivity and Edge Connectivity
(not currently included in overheads)
Connectedness in Directed Graphs
Paths and Isomorphism (not currently
included in overheads)
Counting Paths between Vertices
Paths
Informal Definition: A path is a sequence of
edges that begins at a vertex of a graph and
travels from vertex to vertex along edges of the
graph. As the path travels along its edges, it
visits the vertices along this path, that is, the
endpoints of these.
Applications: Numerous problems can be
modeled with paths formed by traveling along
edges of graphs such as:
Multigraph
Model of the
Bridges of
Kӧnigsberg
The 7 Bridges of
Kӧnigsberg
Euler Paths and Circuits (continued)
Definition: An Euler circuit in a graph G is a simple
circuit containing every edge of G. An Euler path in G is a
simple path containing every edge of G.
Example: Which of the undirected graphs G1, G2, and G3
has a Euler circuit? Of those that do not, which has an
Euler path?
The path begins at a with an edge of the form {a, x}; we show that it must
terminate at a with an edge of the form {y, a}. Since each vertex has an
even degree, there must be an even number of edges incident with this
vertex. Hence, every time we enter a vertex other than a, we can leave it.
Therefore, the path can only end at a.
If all of the edges have been used, an Euler circuit has been constructed.
Otherwise, consider the subgraph H obtained from G by deleting the edges
already used.
In the example H consists of
the vertices c, d, e.
Sufficient Conditions for Euler Circuits
and Paths (continued)
Because G is connected, H must have at least one vertex in common with the
circuit that has been deleted.
Euler paths and circuits contained every edge only once. Now we look at paths and
circuits that contain every vertex exactly once.
William Hamilton invented the Icosian puzzle in 1857. It consisted of a wooden
dodecahedron (with 12 regular pentagons as faces), illustrated in (a), with a peg at
each vertex, labeled with the names of different cities. String was used to used to plot
a circuit visiting 20 cities exactly once
The graph form of the puzzle is given in (b).
That is, a simple path x0, x1, …, xn-1, xn in the graph G = (V, E)
is called a Hamilton path if V = {x0, x1, … , xn-1, xn } and xi ≠ xj
for 0≤ i < j ≤ n, and the simple circuit x0, x1, …, xn-1, xn, x0
(with n > 0) is a Hamilton circuit if x0, x1, … , xn-1, xn is a
Hamilton path.
Hamilton Paths and Circuits
(continued)
Example: Which of these simple graphs has a
Hamilton circuit or, if not, a Hamilton path?