Lecture 14 - DM
Lecture 14 - DM
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.
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 | .
vV vV
Example. The cycle Cn , n 3 , consists of n vertices v1 , v2 , ..., vn and edges {v1 , v2 }, {v2 , v3 },
...,{vn1 , 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.
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 – петля
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.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.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.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).