Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Lecture 11

Graphs
We will introduce the different types of graphs by showing how each can be used to model a
computer network. Suppose that a network is made up of computers and telephone lines between
computers. We can represent the location of each computer by a point and each telephone line by an
arc, as shown in Figure below.

There is at most one telephone line between two computers in this network, each line operates in
both directions, and no computer has a telephone line to itself. Consequently, this network can be
modeled using a simple graph, consisting of vertices that represent the computers and undirected
edges that represent telephone lines, where each edge connects two distinct vertices and no two
edges connect the same pair of vertices.
A simple graph G  (V , E) consists of V, a nonempty set of vertices, and E, a set of unordered pairs
of distinct elements of V, called edges.
Sometimes there are multiple telephone lines between computers in a network. This is the case when
there is a heavy traffic between computers. A network with multiple lines is displayed in Figure
below.

Simple graphs are not sufficient to model such networks. Instead, multigraphs are used, which
consists of vertices and undirected edges between these vertices, with multiple edges between
vertices allowed. Every simple graph is also a multigraph. However, not all multigraphs are simple
graphs, since in multigraph two or more edges may connect the same pair of vertices.
A multigraph G  (V , E) consists of a set V of vertices, a set E of edges, and a function f from E to
{{u, v} | u, v V , u  v} . The edges e1 and e2 are called multiple or parallel edges if f (e1 )  f (e2 ) .
A computer network may connect a telephone line from a computer to itself (perhaps for diagnostic
purposes). Such a network is shown in Figure below.

We cannot use multigraphs to model such networks, since loops, which are edges from a vertex to
itself, are not allowed in multigraphs. Instead, pseudographs are used.
A pseudograph G  (V , E) consists of a set V of vertices, a set E of edges, and a function f from E to
{{u, v} | u, v V } . An edge is a loop if f (e)  {u, u}  {u} for some u V .
The telephone lines in a computer network may not operate in both directions. For instance, in Figure
below the host computer in New York can only receive data from other computers and cannot send
out data. The other telephone lines operate in both directions and are represented by pairs of edges in
opposite directions.
A directed graph G  (V , E) consists of a set V of vertices and a set E of edges that are ordered pairs
of elements of V. In a directed graph loops, ordered pairs of the same element, are allowed, but
multiple edges in the same direction between two vertices are not.
Finally, multiple lines may be present in the computer network, so that there may be several one-way
lines to the host in New York from each location, and perhaps more than one line back to each
remote computer from the host.

A directed multigraph G  (V , E) consists of a set V of vertices, a set E of edges, and a function f


from E to {{u, v} | u, v V } . The edges e1 and e2 are called multiple edges if f (e1 )  f (e2 ) .
Two vertices u and v in an undirected graph G are called adjacent (or neighbors) in G if {u, v} is an
edge of G. If e = {u, v}, the edge e is called incident with the vertices u and v. The edge e is also said
to connect u and v. The vertices u and v are called endpoints of the edge {u, v}.
The degree of a vertex in an undirected graph is the number of edges incident with it, except that a
loop at a vertex contributes twice to the degree of that vertex. The degree of the vertex v is denoted
by deg(v).
Example. What are the degrees of the vertices in the graph G and H?

Solution: In G, deg(a) = 2, deg(b) = deg(c) = deg(f) = 4, deg(d) = 1, deg(e) = 3 and deg(g) = 0.


In H, deg(a) = 4, deg(b) = deg(e) = 6, deg(c) = 1 and deg(d) = 5.
A vertex of degree 0 is called isolated. A vertex is pendant iff it has degree 1.
What do we get when we add the degrees of all the vertices of a graph G  (V , E) ? Each edge
contributes 2 to the sum of the degrees of the vertices since an edge is incident with exactly two
(possibly equal) vertices. This means that the sum of the degrees of the vertices is twice the number
of edges. We the following result, which is sometimes called the Handshaking Theorem, because of
the analogy between an edge having two endpoints and a handshake involving two hands.
Theorem 1 (The Handshaking Theorem). Let G  (V , E) be an undirected graph with e edges. Then
2e   deg(v) . (Note that this applies even if multiple edges and loops are present.)
vV
Example. How many edges are there in a graph with 10 vertices each of degree 6?
Solution: Since the sum of the degrees of the vertices is 6 10  60 , it follows that 2e = 60. Therefore,
e = 30.
Theorem 2. An undirected graph has an even number of vertices of odd degree.
Proof: Let V1 and V2 be the set of vertices of even degree and the set of vertices of odd degree,
respectively, in an undirected graph G  (V , E) . Then 2e   deg( v)   deg( v)   deg( v) . Since
vV vV1 vV2

deg(v) is even for v V1 , the first term in the right-hand side of the last equality is even. Furthermore,
the sum of the two terms on the right-hand side of the last equality is even, since this sum is 2e.
Hence, the second term in the sum is also even. Since all the terms in this sum are odd, there must be
an even number of such terms. Thus, there is an even number of vertices of odd degree.
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.
In a graph with directed edges the in-degree of a vertex v, denoted by deg  (v) , is the number of
edges with v as their terminal vertex. The out-degree of v, denoted by 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 this vertex.
Example. Find the in-degree and out-degree of each vertex in the graph G with directed edges.
Solution: 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 .

Since each edge has an initial vertex and a terminal vertex, the sum of the in-degrees and the sum of
the out-degrees of all vertices in a graph with directed edges are the same. Both of these sums are the
number of edges in the graph. This result is stated as the following theorem.
Theorem 3. Let G  (V , E) be a graph with directed edges. Then  deg (v)  deg (v) | E | .
vV vV

Some special simple graphs


Example. The complete graph on n vertices, denoted by Kn, is the simple graph that contains exactly
one edge between each pair of distinct vertices.

Example. The cycle Cn , n  3 , consists of n vertices v1 , v2 , ..., vn and edges {v1 , v2 }, {v2 , v3 },
...,{vn1 , vn } and {vn , v1} .

Example. We obtain the wheel Wn when we add an additional vertex to the cycle Cn, for n  3 , and
connect this new vertex to each of the n vertices in Cn, by new edges.

Example. The n-cube, denoted by Qn, is the graph that has vertices representing the 2n bit strings of
length n. Two vertices are adjacent iff the bit strings that they represent differ in exactly one bit
position.

Bipartite graphs
A simple graph G is called bipartite if its vertex set V can be partitioned into two disjoint nonempty
sets V1 and V2 such that every edge in the graph connects a vertex in V1 and a vertex in V2 (so that no
edge in G connects either two vertices in V1 or two vertices in V2).
Example. C6 is bipartite since its vertex set can be partitioned into the two sets V1  {v1 , v3 , v5 } and
V2  {v2 , v4 , v6 } , and every edge of C6 connects a vertex in V1 and a vertex in V2.
Example. K3 is not bipartite. To see this, note that if we divide the vertex set of K3 into two disjoint
sets, one of the two sets must contain two vertices. If the graph were bipartite, these two vertices
could not be connected by an edge, but in K3 each vertex is connected to every other vertex by an
edge.
Example. Are the graphs G and H bipartite?

Solution: Graph G is bipartite, since its vertex set is the union of two disjoint sets {a, b, d} and {c, e,
f, g}, and each edge connects a vertex in one of these subsets to a vertex in the other subset. Note that
for G to be bipartite it is not necessary that every vertex in {a, b, d} be adjacent to every vertex in {c,
e, f, g}. For instance, b and g are not adjacent.
Graph H is not bipartite since its vertex set cannot be partitioned into two subsets so that edges do
not connect two vertices from the same subset.
Example. The complete bipartite graph K m ,n is the graph that has its vertex set partitioned into two
subsets of m and n vertices, respectively. There is an edge between two vertices iff one vertex is in
the first subset and the other vertex is in the second subset.

New graphs from old


When edges and vertices are removed from a graph, without removing endpoints of any remaining
edges, a smaller graph is obtained. Such a graph is called a subgraph of the original graph.
A subgraph of a graph G  (V , E) is a graph H  (W , F ) where W  V and F  E .
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. Find the union of the graphs G1 and G2.

Solution: The vertex set of the union G1  G2 is the union of the two vertex sets, namely, {a, b, c, d,
e, f}. The edge set of the union is the union of the two edge sets.

Glossary
adjacent – соседний, смежный; pendant – подвесная, висячая; handshake – рукопожатие
bipartite – двусторонний; loop – петля

Exercises for Seminar 11


11.1. Draw graph models, stating the type of graph used, to represent airline routes where every day
there are four flights from Boston to Newark, two flights from Newark to Boston, three flights from
Newark to Miami, two flights from Miami to Newark, one flight from Newark to Detroit, two flights
from Detroit to Newark, three flights from Newark to Washington, two flights from Washington to
Newark, and one flight from Washington to Miami, with
a) an edge between vertices representing cities that have a flight between them (in either direction).
b) an edge between vertices representing cities for each flight that operates between them (in either
direction).
c) an edge from a vertex representing a city where a flight starts to the vertex representing the city
where it ends.
11.2. Determine whether the graph shown is a simple graph, a multigraph (and not a simple graph), a
pseudograph (and not a multigraph), a directed graph, or a directed multigraph (and not a directed
graph).

11.3. Find the number of vertices, the number of edges, and the degree of each vertex in the given
undirected graph. Identify all isolated and pendant vertices. Find the sum of the degrees of the
vertices of each graph and verify that it equals twice the number of edges in the graph.

11.4. Determine whether the graph is bipartite.

11.5. Does there exist a simple graph with five vertices of the following degrees? If so, draw such a
graph. a) 3, 3, 3, 3, 2; b) 1, 2, 3, 4, 5; c) 0, 1, 2, 2, 3.
11.6. How many subgraphs with at least one vertex does K2 have?
11.7. Find the union of the given pair of simple graphs (assume edges with the same endpoints are
the same).

11.8. Draw all subgraphs of the following graph.

11.9. Draw the following graphs: a) K 7 b) K 1,8 c) K 4 , 4 d) C 7 e) W 7 f) Q 4 .


11.10. For which values of n are the following graphs bipartite? a) K n ; b) C n ; c) W n .
11.11. How many vertices and how many edges do the following graphs have?
a) K n ; b) C n ; c) W n ; d) K m ,n .
Exercise for Homework 11
11.12. Draw graph models, stating the type of graph used, to represent airline routes where every day
there are four flights from Boston to Newark, two flights from Newark to Boston, three flights from
Newark to Miami, two flights from Miami to Newark, one flight from Newark to Detroit, two flights
from Detroit to Newark, three flights from Newark to Washington, two flights from Washington to
Newark, and one flight from Washington to Miami, with
a) an edge between vertices representing cities for each flight that operates between them (in either
direction), plus a loop for a special sightseeing trip that takes off and lands in Miami.
b) an edge for each flight from a vertex representing a city where the flight begins to the vertex
representing the city where the flight ends.
11.13. Determine whether the graph shown is a simple graph, a multigraph (and not a simple graph),
a pseudograph (and not a multigraph), a directed graph, or a directed multigraph (and not a directed
graph).

11.14. Determine the number of vertices and edges and find the in-degree and out-degree of each
vertex for the given directed multigraph. For each of the graphs determine the sum of the in-degrees
of the vertices and the sum of the out-degrees of the vertices directly. Show that they are both equal
to the number of edges in the graph.

11.15. Determine whether the graph is bipartite.

11.16. Does there exist a simple graph with five vertices of the following degrees? If so, draw such a
graph. a) 1, 2, 3, 4, 4; b) 3, 4, 3, 4, 3; c) 1, 1, 1, 1, 1.
11.17. How many subgraphs with at least one vertex does K3 have?
11.18. Find the union of the given pair of simple graphs (assume edges with the same endpoints are
the same).

You might also like