0% found this document useful (0 votes)
40 views67 pages

Chapter10 (2 3)

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

Chapter10 (2 3)

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

Section 10.

2
Graph Terminology and
Special Types of Graphs
Section Summary
Basic Terminology
Some Special Types of Graphs
Bipartite Graphs
Bipartite Graphs and Matchings (not
currently included in overheads)
Some Applications of Special Types of
Graphs (not currently included in
overheads)
New Graphs from Old
Basic Terminology
Definition 1. Two vertices u, v in an
undirected graph G are called adjacent (or
neighbors) in G if there is an edge e
between u and v. Such an edge e is called
incident with the vertices u and v and e is
said to connect u and v.

adjacent 邻接的,相邻
[ə'dʒeɪs(ə)nt] adj.
Basic Terminology
Definition 2. The set of all neighbors
of a vertex v of G = (V, E), denoted by
N(v), is called the neighborhood of v. If
A is a subset of V, we denote by N(A)
the set of all vertices in G that are
adjacent to at least one vertex in A. So,
incident 关联的
Basic Terminology ['ɪnsɪdənt] adj.

Definition 3. The degree of a vertex in a


undirected graph is the number of edges
incident with it, except that a loop at a
vertex contributes two to the degree of
that vertex. The degree of the vertex v is
denoted by deg(v).
A vertex of degree zero is called
isolated.
A vertex is pendant if and only if it has
degree one.
Degrees and Neighborhoods
of Vertices
Example: What are the degrees and neighborhoods of
the vertices in the graphs G and H?
Degrees and Neighborhoods
of Vertices

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.
Degrees of Vertices
Theorem 1 :
Handshaking Theorem
We now give two examples illustrating the
usefulness
of the handshaking theorem.
Example: How many edges are there in a graph
with 10 vertices of degree six?
Solution: Because the sum of the degrees of the
vertices is 6  10 = 60, the handshaking
theorem tells us that 2m = 60. So the number
of edges m = 30.
Handshaking Theorem
Example: If a graph has 5 vertices, can each
vertex have degree 3?
Solution: This is not possible by the
handshaking thorem, because the sum of the
degrees of the vertices 3  5 = 15 is odd.
Degree of Vertices
(continued)
Theorem 2: An undirected graph has an even number of
vertices of odd degree.
Proof: Let V1 be the vertices of even degree and V2 be the
vertices of odd degree in an undirected graph
G = (V, E) with m edges. Then

even

2m is even and the sum of the


This sum must be even because

must be degrees of the vertices of even


even since degrees is also even. Because
deg(v) is this is the sum of the degrees

each v ∈ V1
even for of all vertices of odd degree in
the graph, there must be an
even number of such vertices.
Directed Graphs
Recall the definition of a directed graph.

Definition: An directed graph G = (V, E)


consists of V, a nonempty set of vertices (or
nodes), and E, a set of directed edges or arcs.
Each edge is an ordered pair of vertices. The
directed edge (u,v) is said to start at u and
end at v.
Directed Graphs
Definition: When (u, v) is an edge of the
graph G with directed edges, u is said to
be adjacent to v and v is said to be
adjacent from u. The vertex u is called
the initial vertex of (u, v), and v is called
the terminal or end vertex of (u, v). The
initial vertex and terminal vertex of a
loop are the same.
Directed Graphs
(continued)
Definition: The in-degree of a vertex v,
denoted deg−(v), is the number of edges
which terminate at v. The out-degree of v,
denoted deg+(v), is the number of edges
with v as their initial vertex. Note that a
loop at a vertex contributes 1 to both the
in-degree and the out-degree of the vertex.
Directed Graphs
(continued)
Example: In the graph G we have

deg−(a) = 2, deg−(b) = 2, deg−(c) = 3,


deg−(d) = 2, deg−(e) = 3, deg−(f) = 0.
deg+(a) = 4, deg+(b) = 1, deg+(c) = 2,
deg+(d) = 2, deg+ (e) = 3, deg+(f) = 0.
Directed Graphs
(continued)
Theorem 3: Let G = (V, E) be a graph
with directed edges. Then:

Proof: The first sum counts the number


of outgoing edges over all vertices and
the second sum counts the number of
incoming edges over all vertices. It
follows that both sums equal the number
of edges in the graph.
Directed Graphs
(continued)
Definition: The undirected graph that results
from ignoring directions of edges is called
the underlying undirected graph.
Special Types of Simple
Graphs: Complete Graphs
Definition: A complete graph on n
vertices, denoted by Kn, is the simple
graph that contains exactly one edge
between each pair of distinct vertices.
Special Types of Simple
Graphs: Cycles and Wheels
Definition: A cycle Cn for n ≥ 3 consists
of n vertices v1, v2 ,⋯ , vn, and edges {v1,
v2}, {v2, v3} ,⋯ , {vn-1, vn}, {vn, v1}.
Special Types of Simple
Graphs: Cycles and Wheels
Definition: A wheel Wn is obtained by
adding an additional vertex to a cycle Cn for
n ≥ 3 and connecting this new vertex to
each of the n vertices in Cn by new edges.
Special Types of Simple Graphs:n-
Cubes
Definition: An n-dimensional hypercube, or n-
cube, denoted by Qn, is a graph with 2n
vertices representing all bit strings of length
n, where there is an edge between two
vertices that differ in exactly one bit position.
Special Types of Graphs and
Computer Network
Architecture
Various special graphs play an important role in the
design of computer networks.
local area networks : 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.

topology 拓扑(结构)
[tə'pɒlədʒɪ] n.
Special Types of Graphs and
Computer Network
Architecture
Special Types of Graphs and
Computer Network
Architecture
bipartite 二分的
Bipartite Graphs [baɪ'pɑː(r)taɪt] adj.

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.
Bipartite Graphs
It is not hard to show that an equivalent
definition of a bipartite graph is a graph where it
is possible to color the vertices red or blue so
that no two adjacent vertices are the same color.
a f

b e

c d

G is bipartite H is not bipartite


since if we color a red, then
the adjacent vertices f and b
must both be blue.
Bipartite Graphs
(continued)
Example: Show that C6 is bipartite.

Solution: We can partition the vertex set into

V1 = {v1, v3, v5} and V2 = {v2, v4, v6} so that every


edge of C6 connects a vertex in V1 and V2 .
Bipartite Graphs
(continued)
Example: Show that C3 is not bipartite.

Solution: If we divide the vertex set of C3 into


two nonempty sets, one of the two must
contain two vertices. But in C3 every vertex is
connected to every other vertex. Therefore,
the two vertices in the same partition are
connected. Hence, C3 is not bipartite.
Complete Bipartite Graphs
Definition: A complete bipartite graph K m,n
is a graph that has its vertex set partitioned
into two subsets V1 of size m and V2 of size
n such that there is an edge from every
vertex in V1 to every vertex in V2.
Complete Bipartite Graphs
Example: We display four complete bipartite
graphs here.
Bipartite Graphs and
Matchings
Bipartite graphs are used to model applications
that involve matching the elements of one set
to elements in another, for example:
Job assignments - vertices represent the jobs
and the employees, edges link employees with
those jobs they have been trained to do. A
common goal is to match jobs to employees so
that the most jobs are done.
Bipartite Graphs and
Matchings
Marriage - vertices represent the men and
the women and edges link a a man and a
woman if they are an acceptable spouse.
We may wish to find the largest number of
possible marriages.

See the text for more


about matchings in
bipartite graphs.
Special Types of Graphs and
Computer Network
Architecture
Special Types of Graphs and
Computer Network
Architecture
Special Types of Graphs and
Computer Network
Architecture

illustrated here for 16 processors.


Another common method is the mesh network,
Special Types of Graphs and
Computer Network
Architecture
The n-dimensional hypercube, or n-cube, Qn, is
a common way to connect processors in
parallel, e.g., Intel Hypercube.

The hypercube network balances the


number of direct connections for each
processor and the number of intermediate
connections required so that processors can
communicate.
New Graphs from Old

Example: Here we show K5 and one of its subgraphs.


New Graphs from Old
Definition: Let G = (V, E) be a simple
graph. The subgraph induced by a
subset W of the vertex set V is the graph
(W, F), where the edge set F contains an
edge in E if and only if both endpoints are
in W.
Example: Here we show K5 and the subgraph
induced by W = {a,b,c,e}.
New Graphs from Old
(continued)
Definition: The union of two simple graphs
G1 = (V1, E1) and G2 = (V2, E2) is the simple
graph with vertex set V1 ⋃ V2 and edge set E1 ⋃
E2. The union of G1 and G2 is denoted by G1 ⋃ G2.
Example:
Section 10.3
Representing Graphs and
Graph Isomorphism
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:
Representing Graphs:
Adjacency Lists

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.
 In other words, if the graphs adjacency matrix

is AG = [aij], then
Adjacency Matrices
(continued)
Example:

The ordering of
vertices is a, b, c,
d.

The ordering of
vertices is a, b, c,
d.

Note: The adjacency matrix of a simple graph is symmetric,

aij for i = 1, 2, 3, …, n, is 0.
i.e., aij = aji . Also, since there are no loops, each diagonal entry
TRADE-OFFS BETWEEN
ADJACENCY LISTS AND
ADJACENCY MATRICES

 When a graph is sparse, that is, it has


few edges relatively to the total
number of possible edges, it is much
more efficient to represent the graph
using an adjacency list than an
adjacency matrix.
 But for a dense graph, which includes a
high percentage of possible edges, an
adjacency matrix is preferable.
Adjacency Matrices
(continued)
Adjacency matrices can also be used to
represent graphs with loops and multiple edges.
 A loop at the vertex vi is represented by a 1 at
the (i, j)th position of the matrix.
 When multiple edges connect the same pair of
vertices vi and vj, (or if multiple loops are
present at the same vertex), the (i, j)th entry
equals the number of edges connecting the pair
of vertices.
Adjacency Matrices
(continued)
Example: We give the adjacency matrix of the
pseudograph shown here using the ordering of
vertices a, b, c, d.
Adjacency Matrices
(continued)
Adjacency matrices can also be used to represent
directed graphs.
The matrix for a directed graph G = (V, E) has a 1
in its (i, j)th position if there is an edge from vi to
vj, where v1, v2, … vn is a list of the vertices.
 In other words, if the graphs adjacency matrix
is
AG = [aij], then
Adjacency Matrices
(continued)
 The adjacency matrix for a directed
graph does not have to be symmetric,
because there may not be an edge from
vi to vj, when there is an edge from vj to
vi.
 To represent directed multigraphs, the
value of aij is the number of edges
connecting vi to vj.
Representation of Graphs:
Incidence Matrices
Definition: Let G = (V, E) be an undirected
graph with vertices where v1, v2, … vn and
edges e1, e2, … em. The
incidence matrix with respect to the
ordering of V and E is the n × m matrix
M = [mij], where
Incidence Matrices
(continued)
Example: Simple Graph and Incidence Matrix

The rows going from top to


bottom represent v1
through v5 and
the columns going from left
to right represent e1
through e6.
Incidence Matrices
(continued)
Example: Pseudograph and Incidence Matrix

The rows going from top to


bottom represent v1
through v5 and
the columns going from left
to right represent e1
through e8.
Isomorphism of Graphs
Definition: The simple graphs G1 = (V1, E1)
and G2 = (V2, E2) are isomorphic if there
is a one-to-one and onto function f from V1 to
V2 with the property that a and b are adjacent
in G1 if and only if f(a) and f(b) are adjacent in
G2 , for all a and b in V1 . Such a function f is
called an isomorphism. Two simple graphs that
are not isomorphic are called nonisomorphic.
Isomorphism of Graphs
(cont.)
Example: Show that the graphs G =(V, E) and
H = (W, F) are isomorphic.

Solution: The function f with f(u1) = v1,


f(u2) = v4, f(u3) = v3, and f(u4) = v2 is a
one-to-one correspondence between V
and W. Note that adjacent
vertices in G are u1 and u2, u1 and u3, u2
and u4, and u3 and u4. Each of the pairs
f(u1) = v1 and f(u2) = v4, f(u1) = v1 and
f(u3) = v3 , f(u2) = v4 and f(u4) = v2 ,
and f(u3) = v3 and f(u4) = v2 consists of
two adjacent vertices in H.
Isomorphism of Graphs
(cont.)
It is difficult to determine whether two simple
graphs are isomorphic using brute force because
there are n! possible one-to-one correspondences
between the vertex sets of two simple graphs with
n vertices.
The best algorithms for determining whether two
graphs are isomorphic have exponential worst
case complexity in terms of the number of
vertices of the graphs.
Isomorphism of Graphs
(cont.)
Sometimes it is not hard to show that two graphs
are not isomorphic. We can do so by finding a
property, preserved by isomorphism, that only
one of the two graphs has. Such a property is
called graph invariant.
There are many different useful graph invariants
that can be used to distinguish nonisomorphic
graphs, such as the number of vertices, number of
edges, and degree sequence (list of the degrees
of the vertices in nonincreasing order). We will
encounter others in later sections of this chapter.
Isomorphism of Graphs
(cont.)
Isomorphism of Graphs
(cont.)
Example: Determine whether these two
graphs are isomorphic.
Isomorphism of Graphs
(cont.)

Solution: Both graphs have eight vertices and ten


edges.
They also both have four vertices of degree two
and four of degree three.
However, G and H are not isomorphic. Note that
since deg(a) = 2 in G, a must correspond to t, u, x,
or y in H, because these are the vertices of degree
2. But each of these vertices is adjacent to another
vertex of degree two in H, which is not true for a in
G.
Isomorphism of Graphs
(cont.)
Alternatively, note that the subgraphs of G
and H made up of vertices of degree three
and the edges connecting them must be
isomorphic.
But the subgraphs, as shown at the right,
are not isomorphic.
Isomorphism of Graphs
(cont.)
Example: Determine whether these two graphs
are isomorphic.

Solution: Both graphs have six vertices and


seven edges. They also both have four vertices
of degree two and two of degree three.
The subgraphs of G and H consisting of all the
vertices of degree two and the edges
connecting them are isomorphic. So, it is
reasonable to try to find an isomorphism f.
Isomorphism of Graphs
(cont.)
 We define an injection f from the vertices of G
to the vertices of H that preserves the degree
of vertices.
We will determine whether it is an isomorphism.
 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.
Isomorphism of Graphs
(cont.)
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.
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.
Applications of Graph
Isomorphism
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.

You might also like