Chapter10 V02-Amal
Chapter10 V02-Amal
Chapter 10
© 2019 McGraw-Hill Education. All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw-Hill Education.
Chapter Summary
• 10.1 Graphs and Graph Models
• 10.2 Graph Terminology and Special Types of Graphs
• 10.3 Representing Graphs and Graph Isomorphism
• 10.4 Connectivity
• 10.6 Euler and Hamiltonian Graphs
• 10.7 Shortest-Path Problems (not currently included in
overheads)
• 10.8 Planar Graphs (not currently included in overheads)
• 10.9 Graph Coloring (not currently included i-n
overheads)
© 2019 McGraw-Hill Education
Graphs and Graph Models
Section 10.1
• Introduction to Graphs
• Graph Taxonomy
• Graph Models
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.
© 2019 McGraw-Hill Education
Some Terminology 1
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.
multiplicity of (b,c) is 2.
© 2019 McGraw-Hill Education
Graph Models:
Computer Networks 1
• 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
Solution:
G: deg(a) = 2, deg(b) = deg(c) = deg(f ) = 4, deg(d ) = 1,
deg(e) = 3, deg(g) = 0. Vertix g in graph G is
called isolated
N(a) = {b, f }, N(b) = {a, c, e, f }, N(c) = {b, d, e, f }, N(d)
= {c},
Vertix d in graph G is
N(e) = {b, c , f }, N(f) = {a, b, c, e}, N(g) = . called pendant
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}.
Jump to long description
© 2019 McGraw-Hill Education
© 2019 McGraw-Hill Education
© 2019 McGraw-Hill Education
Degrees of Vertices
Theorem 1 (Handshaking Theorem): If G = (V,E) is an undirected
graph with m edges, then
2m vV deg v
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.
Think about the graph where vertices represent the people at a party
and an edge connects two people who have shaken hands.
v V v V
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.
for 16 processors.
• Another common method is the mesh network, illustrated here
Jump to long description
© 2019 McGraw-Hill Education
Bipartite Graphs 1
H is not bipartite
G is since if we color a
bipartite red, then the
adjacent vertices f
and b must both
be blue.
Marriage - vertices represent the men and the women and edges link 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.
Jump to long description
© 2019 McGraw-Hill Education
New Graphs from Old 2
• Adjacency Lists
• Adjacency Matrices
• Incidence Matrices
• Isomorphism of Graphs
Note: The adjacency matrix of a simple graph is symmetric, i.e., aij = aji
Also, since there are no loops, each diagonal entry aii for i = 1, 2, 3, …, n, is
0.
© 2019 McGraw-Hill Education
Representation of Graphs: Adjacency
Matrices 3
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.
Example: We give the adjacency matrix of the pseudograph shown here using
the ordering of vertices a, b, c, d.
0 3 0 2
3 0 1 1
0 1 1 2
2 1 2 0
(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
1 if vi , v j is an edge of G,
aij
0 otherwise.
• Does the adjacency matrix of a di-graph be symmetric?
• 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.
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.
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.
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.
See the text for an illustration of how adjacency matrices can be used for this verification.
Jump to long description
© 2019 McGraw-Hill Education
Connectivity
Section 10.4
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
© 2019 McGraw-Hill Education
Paths 1
• When the graph is simple, we denote this path by its vertex sequence
x0, x1, … , xn(since listing the vertices uniquely determines the path).
• The path is a circuit if it begins and ends at the same vertex (u = v) and has length
greater than zero.
• The path or circuit is said to pass through the vertices x1, x2, … , xn-1 and traverse
the edges e1, … , en.
• A path or circuit is simple if it does not contain the same edge more than once.
This terminology is readily extended
to directed graphs. (see text)
• d, e, c, a
• is not a path because e is not connected to c.
• b, c, f, e, b is a
• circuit of length 4.
• a, b, e, d, a, b
• is a path of length 5, but it is not a simple path.
The vertices are San Francisco, Los Angeles, Denver. Chicago, Detroit, New York, and
Washington. The edges are from San Francisco to Los Angeles, from San Francisco to
Denver, from Los Angeles to Denver. From Denver to Chicago, from Chicago to Detroit,
from Chicago to Washington. From Chicago to New York. From Detroit to New York,
and from Washington to New York.
2 edges between Los Angeles and Denver, 3 edges between Denver and Chicago, 2
edges between Chicago and New York, and 2 edges between New York and
Washington.
The vertices are San Francisco, Los Angeles, Denver. Chicago, Detroit, New York, and
Washington. The edges are directed from San Francisco to Los Angeles, from San
Francisco to Denver. From Los Angeles to Denver, from Denver to Los Angeles. From
Denver to Chicago, from Chicago to Denver. From Chicago to Detroit, from Detroit to
Chicago. From Chicago to Washington, from Washington to Chicago. From Chicago to
New York, from Detroit to New York, and from Washington to New York.
The vertices are San Francisco, Los Angeles, Denver. Chicago, Detroit, New York, and
Washington. The edges are directed from San Francisco to Los Angeles, from Los
Angeles to San Francisco. 2 from San Francisco to Denver, from Denver to San
Francisco. From Los Angeles to Denver, from Denver to Los Angeles. 2 from Denver to
Chicago, 2 from Chicago to Denver. From Chicago to Detroit, from Detroit to New York,
2 from Chicago to New York. From Chicago to Washington, from Washington to
Chicago. And 2 from Washington to New York.
Appendix
The vertices are Kamini, Jan, Lila. Joel, Kari, Paula. Liz, Gail, Eduardo. Amy, Todd, Steve,
Shaquira, Koko, Kamlesh, Ching. The edges are from Kamini to Jan, from Jan to Lila,
Joel, and Paula. From Lila to Joel, Paula, Liz, and Gail. From Joel to Kari, Paula, and Gail.
From Gail to Shaquira. From Paula to Eduardo, Todd, Amy, and Liz. From Liz to Amy and
Steve. From Steve to Amy, Todd, Koko, and Shaquira. From Todd to Amy and Kamlesh.
And from Kamlesh to Ching.
The vertices are Linda, Brian, Deborah, Fred, and Yvonne. The edges are directed from
Deborah to Linda, Brian, and Fred. From Brian to Linda. From Fred to Brian. From
Yvonne to Fred. From Brian to Yvonne, and from Yvonne to Brian.
Appendix
The vertices are main, display, parser, protocol. Abstract syntax tree, page, and
network. The edges are directed from main to display, parser, protocol, and abstract
syntax tree. From display and parser to abstract syntax tree. From parser and protocol
to page. And from protocol to network.
Appendix
The vertices are from S 1 through S 6. Each vertex stands for an equation. S 1 is for
a:=0, S 2 is for b:=1, S 3 is for c:=a+1. S 4 is for d:=b+a. S 5 is for e:=d+1. And S 6 is for
e:=c+d. S 1 and S 2 are located at the bottom of the graph, S 3 and S 4 are in the
middle, and S5 and S 6 are at the top. The edges are directed from S 1 to S 3, S 4, S 5,
and S 6. From S 2 to S 4, S 5, and S 6. From S 3 to S 6. And from S 4 to S 5 and S 6.
The vertices are Raccoon, Hawk, Owl. Opossum, Squirrel, Crow. Shrew, Mouse, and
Woodpecker. The edges are from Raccoon to Hawk, Owl, and Squirrel. From Hawk to
Owl and Crow. From Owl to Crow. From Squirrel to Crow, Opossum, and Woodpecker.
From Woodpecker to Opossum and Shrew. And from Shrew to Opossum and Mouse.
The vertices are Q9Y3A5, RRP43, RRP42. RRP4, RRP41, RRP44. And RRP40, RRP46 and
PM/Sci2. The edges are from Q9Y3A5 to RRP43, RRP42, RRP4, and RRP41. From RRP43
to RRP42, RRP41, and RRP4. From RRP42 to RRP4 and RRP41. From RRP4 to RRP41,
RRP46, RRP44, and PM/Sci2. From RRP41 to RRP44, RRP46, RRP40, and PM/Sci2. And
from RRP46 to RRP40 and PM/Sci2.
The graph has 12 edges. Arrows point from A to A, from A to B, from A to C. From A to
E, from B to D, from C to B. From C to C, from D to C, from D to E. From E to E, from E
to A, and from E to D.
The vertices form a 4 by 4 grid. The first numbers of each vertex represent rows, and
the second numbers represent columns, starting from 0.
The first graph is complete with 5 vertices. A, B, C, D, and E. The second graph is the
same as previous but with the removed vertex D and corresponding edges. So, the
edges are A B, A C, A E, B C, and B E.
The graph has 6 edges. V1 V4 labeled E1, V1 V5 labeled E2. V2 V4 labeled E3, V2 V5
labeled E4. V2 V3 labeled E6, and V3 V5 labeled E5.
The graph has 8 edges. 2 V1 V2 edges labeled E2 and E3. V2 V3 labeled E4, V3 V5
labeled E5, V2 V5 labeled E6, and V2 V4 labeled E7. There is a loop at vertex V1,
labeled E1, and at vertex V4, labeled E8.
Graph G has 4 vertices. U1, U2, U3, and U4. The graph has 4 edges. U1 U2, U2 U4, U3
U4, and U3 U1. Graph H has 4 vertices. V1, V2, V3, and V4. The graph has 4 edges. V1
V3, V1 V4, V2 V3, and V2 V4.
Graph G has 6 vertices labeled from U1 to U6. The graph has 7 edges. U1 U2, U1 U4,
U2 U3. U2 U6, U3 U4, U4 U5, and U5 U6. Graph H has 6 vertices labeled from V1 to V6.
The graph has 7 edges. V1 V2, V1 V5, V2 V3. V3 V4, V3 V6, V4 V5, and V5 V6.
Appendix
Graph G has 5 vertices. A, B, C, D, and E. The graph has 6 edges. Arrows point from A
to B, from B to C, from B to D. From C to D, from D to E, and from E to A. Graph H has 5
vertices. A, B, C, D, and E. The graph has 6 edges. Arrows point from B to A, from B to
C, from C to D. From D to B, from D to E, and from E to A.