Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf ·...

27
CHAPTER 5 Basic Concepts in Graph Theory Introduction The concepts in this chapter are essential for understanding later discussions involving graphs, so be sure that you understand them. It is not necessary to memorize all the concepts since you can refer back to them if necessary; however, make sure that you understand them when you study them now so that referring back to them will simply be a memory refresher, not a new learning experience. Since the basic concepts in Section 2.1 (p. 41) are used in this chapter, you may wish to review them before continuing. 5.1 What is a Graph? There are various types of graphs, each with its own definition. Unfortunately, some people apply the term “graph” rather loosely, so you can’t be sure what type of graph they’re talking about unless you ask them. After you have finished this chapter, we expect you to use the terminology carefully, not loosely. To motivate the various definitions, we’ll begin with some examples. Example 5.1 A computer network Computers are often linked with one another so that they can interchange information. Given a collection of computers, we would like to describe this linkage in fairly clean terms so that we can answer questions such as “How can we send a message from computer A to computer B using the fewest possible intermediate computers?” We could do this by making a list that consists of pairs of computers that are connected. Note that these pairs are unordered since, if computer C can communicate with computer D, then the reverse is also true. (There are sometimes exceptions to this, but they are rare and we will assume that our collection of computers does not have such an exception.) Also, note that we have implicitly assumed that the computers are distinguished from each other: It is insufficient to say that “A PC is connected to a Mac.” We must specify which PC and which Mac. Thus, each computer has a unique identifying label of some sort. For people who like pictures rather than lists, we can put dots on a piece of paper, one for each computer. We label each dot with a computer’s identifying label and draw a curve connecting two 121

Transcript of Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf ·...

Page 1: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

CHAPTER 5

Basic Conceptsin

Graph Theory

Introduction

The concepts in this chapter are essential for understanding later discussions involving graphs, so besure that you understand them. It is not necessary to memorize all the concepts since you can referback to them if necessary; however, make sure that you understand them when you study them nowso that referring back to them will simply be a memory refresher, not a new learning experience.

Since the basic concepts in Section 2.1 (p. 41) are used in this chapter, you may wish to reviewthem before continuing.

5.1 What is a Graph?

There are various types of graphs, each with its own definition. Unfortunately, some people applythe term “graph” rather loosely, so you can’t be sure what type of graph they’re talking about unlessyou ask them. After you have finished this chapter, we expect you to use the terminology carefully,not loosely. To motivate the various definitions, we’ll begin with some examples.

Example 5.1 A computer network Computers are often linked with one another so that theycan interchange information. Given a collection of computers, we would like to describe this linkagein fairly clean terms so that we can answer questions such as “How can we send a message fromcomputer A to computer B using the fewest possible intermediate computers?”

We could do this by making a list that consists of pairs of computers that are connected. Notethat these pairs are unordered since, if computer C can communicate with computer D, then thereverse is also true. (There are sometimes exceptions to this, but they are rare and we will assumethat our collection of computers does not have such an exception.) Also, note that we have implicitlyassumed that the computers are distinguished from each other: It is insufficient to say that “A PC isconnected to a Mac.” We must specify which PC and which Mac. Thus, each computer has a uniqueidentifying label of some sort.

For people who like pictures rather than lists, we can put dots on a piece of paper, one for eachcomputer. We label each dot with a computer’s identifying label and draw a curve connecting two

121

Page 2: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

122 Chapter 5 Basic Concepts in Graph Theory

•EN

•CS

• SE•MN

•RL

•SH

•SM

•TM

Figure 5.1 Computers connected by networks. Computers (vertices) are indicated by dots (•) with labels.The connections (edges) are indicated by lines. When lines cross, they should be thought of as cables thatlie on top of each other—not as cables that are joined.

dots if and only if the corresponding computers are connected. Note that the shape of the curvedoes not matter (it could be a straight line or something more complicated) because we are onlyinterested in whether two computers are connected or not. Figure 5.1 shows such a picture. Eachcomputer has been labeled by the initials of its owner.

Recall that P2(V ) stands for the set of all two element subsets of the set V . Based on ourcomputer example we have

Definition 5.1 Simple graph A simple graph G is a set V , called the vertices of G, anda subset E of P2(V ) (i.e., a set E of 2 element subsets of V ), called the edges of G. We canrepresent this by writing G = (V, E).

In our case, the vertices are the computers and a pair of computers is in E if and only if they areconnected.

Example 5.2 Routes between cities Imagine four cities named, with characteristic mathe-matical charm, A, B, C and D. Between these cities there are various routes of travel, denoted bya, b, c, d, e, f and g. A picture of this situation is shown in Figure 5.2. Looking at it, we see thatthere are three routes between cities B and C. These routes are named d, e and f . Figure 5.2 is in-tended to give us a picture of only the interconnections between cities. It leaves out many aspects ofthe situation that might be of interest to a traveler. For example, the nature of these routes (roughroad, freeway, rail, etc.) is not portrayed. Furthermore, unlike a typical map, no claim is made thatthe picture represents in any way the distances between the cities or their geographical placementrelative to each other. The object shown in Figure 5.2 is called a graph. Edges a and b are calledparallel, as are edges d, e and f .

Following our previous example, one is tempted to list the pairs of cities that are connected; inother words, to extract a simple graph from the information. Unfortunately, this does not describethe problem adequately because there can be more than one route connecting a pair of cities; e.g.,d, e and f connecting cities B and C in the figure. How can we deal with this? Definition 5.2 is aprecise definition of a graph of the type required to handle this type of problem.

Page 3: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

5.1 What is a Graph? 123

•A •B

•C

•D

gc

e

b

a

d

f

Figure 5.2 Capital letters indicate cities and lower case indicate routes.

Definition 5.2 Graph A graph is a triple G = (V, E, ϕ) where V and E are finite setsand ϕ is a function with range P2(V ) and with domain E. We call E the set of edges of thegraph G. The set V is called the set of vertices of G.

In Figure 5.2, G = (V, E, ϕ) where

V = {A, B, C, D}, E = {a, b, c, d, e, f, g}

and

ϕ =(

a b c d e f g

{A,B} {A,B} {A,C} {B,C} {B,C} {B,C} {B,D}

)

.

Definition 5.2. tells us that to specify a graph G it is necessary to specify the sets V and E and thefunction ϕ. We have just specified V and ϕ in set theoretic terms. Figure 5.2 specifies the same Vand ϕ in pictorial terms. The set V is represented clearly in Figure 5.2 by dots (•), each of whichhas a city name adajcent to it. Similarly, the set E is also represented clearly. The function ϕ isdetermined from Figure 5.2 by comparing the name attached to a route with the two cities connectedby that route. Thus, the route name d is attached to the route with endpoints B and C. This meansthat ϕ(d) = {B, C}.

Note that, since part of the definition of a function includes its range and domain, ϕ determinesP2(V ) and E. Also, V can be determined from P2(V ). Consequently, we could have said that agraph is a function ϕ whose domain is a finite set and whose range is P2(V ) for some finite set V .Instead, we choose to specify V and E explicitly because the vertices and edges play a fundamentalrole in thinking about a graph G.

The function ϕ is sometimes called the incidence function of the graph. The two elements ofϕ(x) = {u, v}, for any x ∈ E, are called the vertices of the edge x, and we say u and v are joined byx. We also say that u and v are adjacent vertices and that u is adjacent to v or , equivalently, v isadjacent to u. For any v ∈ V , if v is a vertex of an edge x then we say x is incident on v. Likewise,we say v is a member of x, v is on x, or v is in x. Of course, v is a member of x actually means v isa member of ϕ(x).

Figure 5.3 shows two other pictorial ways of specifying the same graph as in Figure 5.2. Thedrawings look very different but exactly the same set V and function ϕ are specified in each case.It is very important that you understand exactly what information is needed to completely specifythe graph. When thinking in terms of cities and routes between them, you naturally want thepictorial representation of the cities to represent their geographical positioning also. If the pictorialrepresentation does this, that’s fine, but it is not a part of the information required to define a graph.Geographical location is extra information. The geometrical positioning of the vertices A, B, C andD is very different in Figures 5.2 and 5.3(a). However, in each of these cases, the vertices on a given

Page 4: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

124 Chapter 5 Basic Concepts in Graph Theory

•• •

•D

A CB

a

b

d

e

g

f

c

•D

BA

C

g

a, b

c

d, e, f

Figure 5.3 Two alternate pictorial specifications of Figure 5.2.

edge are the same and hence the graphs specified are the same. In Figure 5.3(b) a different method

of specifying the graph is given. There, ϕ−1, the inverse of ϕ, is given. For example, ϕ−1({C, B}) is

shown to be {d, e, f}. Knowing ϕ−1 determines ϕ and hence determines G since the vertices A, B, C

and D are also specified in Figure 5.3(b).

Warning Some people call our “simple graph” a “graph” and some people call our “graph” a

“multigraph.” Still other people mean something somewhat different by the term multigraph!

Example 5.3 Simple graphs are graphs We can easily reconcile our two definitions by real-

izing that a simple graph is a special case of a graph. Let G = (V, E) be a simple graph. Defineϕ: E → E to be the identity map; i.e., ϕ(e) = e for all e ∈ E. The graph G′ = (V, E, ϕ) is essentially

the same as G. There is one subtle difference in the pictures: The edges of G are unlabeled but each

edge of G′ is labeled by a set consisting of the two vertices at its ends.

There are still more concepts that can be called graphs. People may not be interested in which

road is which in Figure 5.2, so the labels on the edges are not needed. On the other hand, some

people might need more information, such as how long it takes to travel on each of the routes in

Figure 5.2. There may be other situations, too; for example, some of the routes may be one way. We

will meet some of these concepts later.

Exercises

5.1.1. Let (V, E, ϕ) be a graph and v ∈ V a vertex. Define the degree of v, d(v) to be the number of e ∈ E

such that v ∈ ϕ(e); i.e., e is incident on v. Prove that∑

v∈Vd(v) = 2|E|, an even number. Conclude

that the number of vertices v for which d(v) is odd is even.

5.1.2. We are interested in the number of simple graphs with V = n.

(a) Prove that there are 2(n

2) such simple graphs. (That’s 2 to the power

(

n2

)

, not 2(

n2

)

.)

(b) How many of them have exactly q edges?

(c) If we choose a simple n-vertex graph uniformly at random, what is the probability that it hasexactly q edges?

Page 5: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

5.1 What is a Graph? 125

5.1.3. Sometimes it is useful to allow an edge to have both its ends on the same vertex. Let Q = (V, E, ϕ)be a graph where

V = {A, B, C, D, E, F, G, C, H}, E = {a, b, c, d, e, f, g, h, i, j, d}

and

ϕ =

(

a b c d e f g h i j k

A A D E A E B F G C A

B D E B B G F G C C A

)

.

In this representation of ϕ, the first row specifies the edges and the the two vertices below each edgespecify the vertices incident on that edge. Here is a pictorial representation P (Q) of this graph.

P ′(Q) :• • • • • • • •A D E B F G C H

a f

b c d g h i

e

jk

Note that ϕ(k) = {A, A} = {A}. Such an edge is called a loop. Adding a loop to a vertex increasesits degree by two. The vertex H , which does not belong to ϕ(x) for any edge x (i.e., has no edgeincident upon it), is called an isolated vertex. The degree of an isolated vertex is zero. Edges, suchas a and e of Q, with the property that ϕ(a) = ϕ(e) are called parallel edges. If all edge and vertex

labels are removed from P (Q) then we get the following picture P ′(Q):

P ′(Q) : • • • • • • • •

The picture P ′(Q) represents the “form” of the graph just described and is sometimes referred toas a pictorial representation of the “unlabeled” graph associated with Q. For each of the followinggraphs R, where R = (V, E, ϕ), V = {A, B, C, D, E, F, G, C, H}, draw a pictorial representation of

R by starting with P ′(Q) removing and/or adding as few edges as possible and then labeling theresulting picture with the edges and vertices of R. A graph R which require no additions or removalsof edges is said to be “of the same form as” or “isomorphic to” the graph Q.

(a) Let E = {a, b, c, d, e, f, g, h, i, j, k} be the set of edges of R and

ϕ =

(

a b c d e f g h i j k

C C F A H E E A D A A

C G G H H H F H G D F

)

.

(b) Let E = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} be the set of edges of R and

ϕ =

(

1 2 3 4 5 6 7 8 9 10 11

A E E E F G H B C D E

G H E F G H B C D D H

)

.

Page 6: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

126 Chapter 5 Basic Concepts in Graph Theory

5.1.4. Let Q = (V, E, ϕ) be a graph with |V | = n. Let d1, d2, . . . , dn, where d1 ≤ d2 ≤ · · · ≤ dn bethe sequence of degrees of the vertices of Q, sorted by size. We refer to this sequence as the degree

sequence of the graph Q. For example, if Q = (V, E, ϕ) is the graph where

V = {A, B, C, D, E, F, G, H}, E = {a, b, c, d, e, f, g, h, i, j, k, l}

and

ϕ =

(

a b c d e f g h i j k l

A A D E A E B F G C A E

B D E B B G F G C C A G

)

.

then (0, 2, 2, 3, 4, 4, 4, 5) is the degree sequence of Q. Consider the the following unlabeled pictorialrepresentation of Q

P ′(Q) : • • • • • • • •

(a) Create a pictorial representation of Q by labeling P ′(Q) with the edges and vertices of Q.

(b) A necessary condition that a pictorial representation of a graph R can be created by labeling

P ′(Q) with the vertices and edges of R is that the degree sequence of R be (0, 2, 2, 3, 4, 4, 4, 5).True of false? Explain.

(c) A sufficient condition that a pictorial representation of a graph R can be created by labeling

P ′(Q) with the vertices and edges of R is that the degree sequence of R be (0, 2, 2, 3, 4, 4, 4, 5).True or false? Explain.

5.1.5. In each of the following problems information about the degree sequence of a graph is given. In eachcase, decide if a graph, without loops, satisfying the specified conditions exists or not. Give reasonsin each case.

(a) A graph Q with degree sequence (1, 1, 2, 3, 3, 5)?

(b) A graph Q with degree sequence (1, 2, 2, 3, 3, 5), multiple (i.e. parallel) edges allowed?

(c) A simple graph Q with degree sequence (1, 2, 2, 3, 3, 5)?

(d) A simple graph Q with degree sequence (3, 3, 3, 3)?

(e) A graph Q with degree sequence (3, 3, 3, 3), no loops or parallel edges allowed?

(f) A graph Q with degree sequence (3, 3, 3, 5), no loops or parallel edges allowed?

(g) A graph Q with degree sequence (4, 4, 4, 4, 4), no loops or parallel edges allowed?

(h) A graph Q with degree sequence (4, 4, 4, 4, 6), no loops or parallel edges allowed?

5.2 Equivalence Relations and Unlabeled Graphs

Sometimes we are interested only in the “structure” of a graph and not in the names (labels) of thevertices and edges. In this case we are interested in what is called an unlabeled graph. A picture ofan unlabeled graph can be obtained from a picture of a graph by erasing all of the names on thevertices and edges. This concept is simple enough, but is difficult to use mathematically because theidea of a picture is not very precise.

The concept of an equivalence relation on a set is an important concept in mathematics andcomputer science. We used the idea in Section 4.3, but did not discuss it much there. We’ll exploreit more fully here and will use it to rigorously define unlabeled graphs. Later we will use it to defineconnected components and biconnected components. We recall the definition given in Section 4.3:

Page 7: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

5.2 Equivalence Relations and Unlabeled Graphs 127

Definition 5.3 Equivalence relation An equivalence relation on a set S is a partition

of S. We say that s, t ∈ S are equivalent if and only if they belong to the same block. If the

symbol ∼ denotes the equivalence relation, then we write s ∼ t to indicate that s and t are

equivalent.

Example 5.4 To refresh your memory, we’ll look at some simple equivalence relations.

Let S be any set and let all the blocks of the partition have one element. Two elements of S

are equivalent if and only if they are the same. This rather trivial equivalence relation is, of course,

denoted by “=”.

Now let the set be the integers Z. Let’s try to define an equivalence relation by saying that n

and k are equivalent if and only if they differ by a multiple of 24. Is this an equivalence relation?

If it is we should be able to find the blocks of the partition. There are 24 of them, which we could

number 0, . . . , 23. Block j consists of all integers which equal j plus a multiple of 24; that is, they

have a remainder of j when divided by 24. Since two numbers belong to the same block if and

only if they both have the same remainder when divided by 24, it follows that they belong to the

same block if and only if their difference gives a remainder of 0 when divided by 24, which is the

same as saying their difference is a multiple of 24. Thus this partition does indeed give the desired

equivalence relation.

Now let the set be Z × Z∗, where Z

∗ is the set of all integers except 0. Write (a, b) ∼ (c, d) if

and only if ad = bc. With a moment’s reflection, you should see that this is a way to check if the

two fractions a/b and c/d are equal. We can label each equivalence class with the fraction a/b that

it represents. In an axiomatic development of the rationals from the integers, one defines a rational

number to be just such an equivalence class and proves that it is possible to add, subtract, multiply

and divide equivalence classes. We won’t pursue this.

In the next theorem we provide necessary and sufficient conditions for an equivalence relation.

Verifying the conditions is a useful way to prove that some particular situation is an equivalence

relation. Recall that a binary relation on a set S is a subset R of S × S. Given a binary relation

R, we will write s ∼ t if and only if (s, t) ∈ R. Thus “∼” is another way to represent the binary

relation.

Theorem 5.1 Equivalence relations Let S be a set and suppose that we have a binary

relation ∼ on S. This is an equivalence relation if and only if the following three conditions hold.

(i) (Reflexive) For all s ∈ S we have s ∼ s.

(ii) (Symmetric) For all s, t ∈ S such that s ∼ t we have t ∼ s.

(iii) (Transitive) For all r, s, t ∈ S such that r ∼ s and s ∼ t we have r ∼ t.

Page 8: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

128 Chapter 5 Basic Concepts in Graph Theory

Proof: We first prove that an equivalence relation satisfies (i)–(iii). Suppose that ∼ is an equiv-

alence relation. Since s belongs to whatever block it is in, we have s ∼ s. Since s ∼ t means that

s and t belong to the same block, we have s ∼ t if and only if we have t ∼ s. Now suppose that

r ∼ s ∼ t. Then r and s are in the same block and s and t are in the same block. Thus r and t are

in the same block and so r ∼ t.

We now suppose that (i)–(iii) hold and prove that we have an equivalence relation. What would

the blocks of the partition be? Everything equivalent to a given element should be in the same block.

Thus, for each s ∈ S let B(s) be the set of all t ∈ S such that s ∼ t. We must show that the set of

these sets form a partition of S.

In order to have a partition of S, we must have

(a) every t ∈ S is in some B(s) and

(b) for every p, q ∈ S, B(p) and B(q) are either equal or disjoint.

Since ∼ is reflexive, s ∈ B(s), proving (a). Suppose x ∈ B(p) ∩B(q) and y ∈ B(p). We have, p ∼ x,

q ∼ x and p ∼ y. Thus q ∼ x ∼ p ∼ y and so y ∈ B(q), proving that B(p) ⊆ B(q). Similarly

B(q) ⊆ B(p) and so B(p) = B(q). This proves (b).

Suppose we have a picture of a graph G = (V, E, ϕ), with the elements of V and E written

next to the appropriate vertices and edges in the picture. Suppose that we have another graph

G′ = (V ′, E′, ϕ′). We may be able to erase the elements of V and E and replace them with elements

of V ′ and E′, respectively, so that we obtain a picture of the graph G′. If this is possible, we will

say that G and G′ are isomorphic graphs. One can show that this relation (G is isomorphic to

G′) satisfies the conditions of Theorem 5.1 and so is an equivalence relation. All graphs which are

isomorphic to a given graph correspond to the same unlabeled graph. The following definition and

example formulate these ideas more precisely.

Definition 5.4 Graph isomorphism Let G = (V, E, ϕ) and G′ = (V ′, E′, ϕ′) be graphs.

We say G and G′ are isomorphic, written G ∼ G′ if there are bijections

ν: V → V ′ and ε: E → E′

such that ϕ′(ε(e)) = ν(ϕ(e)) for all e ∈ E, where ν({x, y}) is defined to be {ν(x), ν(y)}.Let G = (V, E) and G′ = (V ′, E′) be simple graphs. They are isomorphic if there is a bijection

ν: V → V ′ such that

{u, v} ∈ E if and only if {ν(u), ν(v)} ∈ E′.

Let’s see what our definition means intuitively. Suppose we have a picture of a graph G =

(V, E, ϕ), with the elements of V and E written next to the appropriate vertices and edges in the

picture. We can replace the vertex set by a new set V ′, writing the elements of V ′ where the elements

of V were. The same thing can be done with the edges and a new set E′. This defines two functions

ν: V → V ′ and ε: E → E′. The condition ϕ′(ε(e)) = ν(ϕ(e)) says that we get ϕ′ by simply looking

at the picture to see what the ends of an edge are.

Page 9: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

5.2 Equivalence Relations and Unlabeled Graphs 129

E1ε1←→

ε−1

1

E2 E1ε1−→ E2

ε2−→ E3

y

ϕ1

y

ϕ2

y

ϕ1

y

ϕ2

y

ϕ3

P2(V1)ν1←→

ν−1

1

P2(V2) P2(V1)ν1−→ P2(V2)

ν2−→ P2(V3)

Figure 5.4 Functions involved in proving the equivalence of graphs. The left diagram is used for thereflexive law. The right diagram is used for the transitive law.

Example 5.5 Unlabeled graphs Let S be the set of all graphs and let G = (V, E, ϕ) andG′ = (V ′, E′, ϕ′) be in S. We will prove that graph isomorphism is an equivalence relation on S.

Before we give our proof, let’s look at how an equivalence class can be interpreted. Draw a pictureof G and then erase the names of the vertices and edges. We could call what is left the “structure” ofG or, as is more commonly done, an unlabeled graph. The use of an equivalence relation to define anunlabeled graph may seem a bit round-about: Why not just be satisfied with the picture? Thinkingabout the picture is fine for thinking about unlabeled graphs and for the proofs we’ll write; however,there are reasons for presenting this definition:

• If we wanted to use the picture approach in a more formal way, we’d have to say precisely whata picture of a graph was and when two pictures represented the same graph. We faced thisproblem a bit in the previous section.

• Equivalence relations arise from isomorphisms in many areas of mathematics and there is oftenno picture that one can use to describe the equivalence relation. Thus, seeing the formalism forgraphs is good preparation for seeing it in other courses.

• If we wanted a theorem-proving computer program to work with unlabeled graphs, we’d needto give it a formal definition. (It would be much simpler to work with labeled graphs.) This isan example of how an intuitively simple concept—unlabeled graphs in this case—can be verydifficult to express in terms that computer software can deal with.

We now give a formal proof that we have an equivalence relation.

First: G ∼ G because we can take ν and ε to be the identity functions; i.e., ν(x) = x for all x ∈ V .

Second: Given that G1 ∼ G2, we must prove G2 ∼ G1, the reflexive law. Let ν1 and ε1 bethe bijections guaranteed by the definition of G1 ∼ G2. Then ν−1

1 : V2 → V1 and ε−11 : E2 → E1

are bijections. Let e2 ∈ E2 and e1 = ε−11 (e2). Then, by ϕ2(ε1(e1)) = ν1(ϕ1(e1)), we have

ϕ1(e1) = ν−11 (ϕ2(ε1(e1))) and so

ϕ1(ε−11 (e2)) = ϕ1(e1) = ν−1

1 (ϕ2(ε1(e1))) = ν−11 (ϕ2(e2)).

Thus G2 ∼ G1.

Figure 5.4 may help you follow what we’ve just done: The definition of G1 ∼ G2 says thatstarting at e ∈ E1, going to E2 via ε1 and then to P2(V2) via ϕ2 ends up at the same pair of verticesas going from e to P2(V1) and then to P2(V2) via ϕ1 and ν1, respectively. In other words, the tworoutes from E1 to P2(V2) end up in the same place. We proved that the two routes from E2 toP2(V1) must then also end up in the same place.

Third: We must prove the transitive law. Suppose that G1 ∼ G2 ∼ G3. We then have the bijectionsνi: Vi → Vi+1 and εi: Ei → Ei+1 for i = 1, 2. Furthermore, ϕi+1(εi(ei)) = νi(ϕi(ei)) for all ei ∈ Ei.Let ν(v1) = ν2(ν1(v1)) and ε(e1) = ε2(ε1(e1)). It is easily verified that ν and ε are bijections sinceνi and εi are. Finally, since ε1(e1) ∈ E2,

ϕ3(ε(e1)) = ϕ3(ε2(ε1(e1))) = ν2(ϕ2(ε1(e1))) = ν2(ν1(ϕ1(e1))) = ν(ϕ1(e1)).

Thus G1 ∼ G3.

Page 10: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

130 Chapter 5 Basic Concepts in Graph Theory

Exercises

5.2.1. Suppose that G = (V, E, ϕ) and G′ = (V ′, E′, ϕ′) are equivalent; i.e., give the same unlabeled graph.Prove the following.

(a) |V | = |V ′| and |E| = |E′|.

(b) d(k,G) = d(k, G′) for all k, where d(k, H) is the number of vertices of degree k in H .

5.2.2. From our discussion, it may seem to be an easy matter to decide if two graphs represent the sameunlabeled graph. This is not true even for relatively small graphs. Divide the following graphs intoequivalence classes and justify your answer; i.e., explain why you have the classes that you do. In allcases V = 4.

(a) ϕ =(

a b c d e f

{1,2} {1,2} {2,3} {3,4} {1,4} {2,4}

)

(b) ϕ =(

A B C D E F

{1,2} {1,4} {1,4} {1,2} {2,3} {3,4}

)

(c) ϕ =(

u v w x y z

{2,3} {1,3} {3,4} {1,4} {1,2} {1,2}

)

(d) ϕ =(

P Q R S T U

{3,4} {2,4} {1,3} {3,4} {1,2} {1,2}

)

5.2.3. Let M(n, R) be the n× n matrices over the real numbers.

(a) For two matrices A, B ∈ M(n, R), write A ' B if and only if there is some nonsingular

P ∈M(n, R) such that B = PAP−1. Prove that this is an equivalence relation.

(b) For two matrices A, B ∈ M(n, R), write A ∼ B if and only if there is some nonsingular

P ∈ M(n, R) such that B = PAP t, where P t is the transpose of P . Prove that this is anequivalence relation.

5.2.4. Which of the following define equivalence relations? If an equivalence relation is not defined, whynot?

(a) For all s and t, s ∼ t.

(b) Among the students at a university who have selected precisely one major, two are equivalent ifand only if they have the same major.

(c) Among the students at a university, two students are equivalent if they have a class in com-mon.

(d) For the real numbers, two numbers are equivalent if they differ by less that 0.001.

(e) For the real numbers, two numbers are equivalent if they agree in their decimal expansionsthrough the third digit after the decimal place.

*5.2.5. Define the concept of a equivalence relation for simple graphs so that you can introduce the notionof an unlabeled simple graph. Prove that you have, indeed, defined an equivalence relation.Hint. You need only introduce ν, not ε.

Page 11: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

5.3 Paths and Subgraphs 131

*5.2.6. We say that an ordinary function f ∈ BA has its domain A and its range B labeled. For convenience,welet A = {1, . . . , a} and B = {1, . . . , b}.

(a) Suppose that f, g ∈ BA. Write f ∼ g if there is a permutation π on A such that f(x) = g(π(x))for all x ∈ A. Prove that this is an equivalence relation. We call the equivalence class a functionwith unlabeled domain. Prove that the set of nondecreasing functions from A to B is a system ofrepresentatives for these equivalence classes; that is, this set contains exactly one function fromeach equivalence class.

(b) Using the idea in (a), define the notion of a function with unlabeled range and prove that youhave an equivalence relation. Call a function f : A→ B a “restricted growth function” if f(1) = 1and, for a > j ≥ 1, f(j + 1) is at most one larger than the maximum of f(1), f(2), . . . , f(j).Prove that the restricted growth functions form a system of representatives for the equivalenceclasses you have defined.

(c) Using the previous ideas, define the notion of a function with unlabeled domain and range andprove that you have an equivalence relation. Call a function f : A → B a “partition function”

if f(i) ≤ f(i + 1) for a > i ≥ 1 and |f (−1)(j)| ≥ |f(−1)(j + 1)| for b > j ≥ 1. Prove that thepartition functions give one representative from each equivalence class

*5.2.7. This problem uses the ideas and notation from the previous problem. Construct a table with fourrows marked with the four possibilities “A (un)labeled and B (un)labeled” and with the columnsmarked with “all,” “injections” and “surjections.” Each of the twelve positions is to be interpreted

as the number of (equivalence classes of) functions in BA satisfying the conditions. We use |A| = aand |B| = b and use U and L to indicate labeled and unlabeled. The start of a table is shown below.Verify these entries and complete the table. How can the number of (equivalence classes of) bijectionsbe found from the table?

A B all injections surjections

L L ? b(b− 1) · · · (b− a + 1) ?

L U∑

k≤bS(a, k) ? ?

U L ? ?

(

a− 1

a− b

)

U U ? 1 ?

5.3 Paths and Subgraphs

An important concept for describing the structure of a graph is the concept of a path.

Definition 5.5 Path, trail, walk and vertex sequence Let G = (V, E, ϕ) be a graph.

Let e1, e2, . . . , en−1 be a sequence of elements of E (edges of G) for which there is a sequence

a1, a2, . . . , an of distinct elements of V (vertices of G) such that ϕ(ei) = {ai, ai+1} for i =

1, 2, . . . , n − 1. The sequence of edges e1, e2, . . . , en−1 is called a path in G. The sequence of

vertices a1, a2, . . . , an is called the vertex sequence of the path. (Note that since the vertices

are distinct, so are the edges.) If we require that e1, . . . , en−1 be distinct, but not that a1, . . . , an

be distinct, the sequence of edges is called a trail. If we do not even require that the edges be

distinct, it is called a walk.

Page 12: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

132 Chapter 5 Basic Concepts in Graph Theory

Note that the definition of a path requires that it not intersect itself (i.e., have repeated vertices),

while a trail may intersect itself. Although a trail may intersect itself, it may not have repeated edges,but a walk may. If P = (e1, . . . , en−1) is a path in G = (V, E, ϕ) with vertex sequence a1, . . . , an

then we say that P is a path from a1 to an. Similarly for a trail or a walk.

In the graph of Figure 5.2 (p. 123), the sequence c, d, g is a path with vertex sequence A, C, B, D.

If the graph is of the form G = (V, E) with E ⊆ P2(V ), then the vertex sequence alone specifies thesequence of edges and hence the path. Thus, in Figure 5.1 (p. 122), the vertex sequence MN, SM,

SE, TM specifies the path {MN, SM}, {SM, SE}, {SE, TM}.

Note that every path is a trail and every trail is a walk, but not conversely. However, we can

show that, if there is a walk between two vertices, then there is a path. This rather obvious resultcan be useful in proving theorems, so we state it as a theorem.

Theorem 5.2 Suppose u 6= v are vertices in G = (V, E, ϕ). The following are equivalent:

(a) There is a walk from u to v.

(b) There is a trail from u to v.

(c) There is a path from u to v.

Furthermore, given a walk from u to v, there is a path from u to v all of whose edges are in the

walk.

Proof: Since every path is a trail, (c) implies (b). Since every trail is a walk, (b) implies (a). Thusit suffices to prove that (a) implies (c). Let e1, e2, . . . , ek be a walk from u to v. We use induction on

n, the number of repeated vertices in a walk. If the walk has no repeated vertices, it is a path. This

starts the induction at n = 0. Suppose n > 0. If u and or v is repeated, take the part of the walkthat starts at the last occurrence of u and ends at the first occurrence of v, since this walk has less

than n repeated vertices, there is a path. Let r be a repeated vertex different from u and v. Suppose

it first appears in edge ei and last appears in edge ej . Then e1, . . . , ei, ej, . . . , ek is a walk from uto v in which r is not a repeated vertex. Hence there are less than n repeated vertices in this walk

from u to v and so there is a path by induction. Since we constructed the path by removing edges

from the walk, the last statement in the theorem follows.

Another basic notion is that of a subgraph of G = (V, E, ϕ), which we will soon define. First weneed some terminology about functions. By a restriction ϕ′ of ϕ to E′ ⊆ E, we mean the function

ϕ′ with domain E′ and satisfying ϕ′(x) = ϕ(x) for all x ∈ E′.

Definition 5.6 Subgraph Let G = (V, E, ϕ) be a graph. A graph G′ = (V ′, E′, ϕ′) is asubgraph of G if V ′ ⊆ V , ϕ(e′) ∈ P2(V

′) for all e′ ∈ E′, and ϕ′ is the restriction of ϕ to E′

having range P2(V′).

The fact that G′ is itself a graph means that ϕ(x) ∈ P2(V′) for each x ∈ E′.

Example 5.6 For the graph G = (V, E, ϕ) of Figure 5.2 (p. 123), Let G′ = (V ′, E′, ϕ′) be definedby V ′ = {A, B, C}, E′ = {a, b, c, f}, and by ϕ′ being the restriction of ϕ to E′ with range P2(V

′).Notice that ϕ′ is determined completely from knowing V ′, E′ and ϕ. Thus, to specify a subgraph

G′, the key information is V ′ and E′.

As another example from Figure 5.2, we let V ′ = V and E′ = {a, b, c, f}. In this case, the vertexD is not a member of any edge of the subgraph. Such a vertex is called an isolated vertex of G′.

Page 13: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

5.3 Paths and Subgraphs 133

One way of specifying a subgraph is to give a set of edges E′ ⊆ E and take V ′ to be the set ofall vertices on some edge of E′. In other words , V ′ is the union of the sets ϕ(x) over all x ∈ E′.Such a subgraph is called the subgraph induced by E′. The first of Examples 5.6 is the subgraphinduced by E′ = {a, b, c, f}. Likewise, given a set V ′ ⊆ V , we can take E′ to be the set of all edgesx ∈ E such that ϕ(x) ⊆ V ′. The resulting subgraph is called the subgraph induced by V ′. Referringto Figure 5.2 (p. 123), the edges of the subgraph induced by V ′ = {C, B}, are E′ = {d, e, f}.

Look again at Figure 5.2. In particular, consider the path c, a with vertex sequence C, A, B.Notice that the edge d has ϕ(d) = {C, B}. The subgraph G′ = (V ′, E′, ϕ′), where V ′ = {C, A, B}and E′ = {c, a, d} is called a cycle of G. In general, whenever there is a path in G, say e1, . . . , en−1

with vertex sequence a1, . . . , an, and an edge x with f(x) = {a1, an}, then the subgraph induced bythe edges e1, . . . , en−1, x is called a cycle of G. The formal definition is:

Definition 5.7 Cycle Let G = (V, E, ϕ) be a graph and let e1, . . . , en−1 be a path withvertex sequence a1, . . . , an. If x is an edge of G such that ϕ(x) = {a1, an}, then the subgraphG′ of G induced by the set of edges {e1, . . . , en−1, x} is called a cycle of G. The length of thecycle is n.

In our definitions, a path is a sequence of edges but a cycle is a subgraph of G. In actual practice,we will not need to make such fine distinctions, so we may think of a cycle as a path, except thatit starts and ends at the same vertex. Cycles are closely related to the existence of unique pathsbetween vertices:

Theorem 5.3 Two vertices u 6= v are on a cycle of G if and only if there are two paths fromu to v that have no vertices in common except the endpoints u and v.

Proof: Suppose u and v are on a cycle. Follow the cycle in some direction from u to v to obtainone path. Then follow the cycle in the opposite direction from u to v to obtain another. Since a cyclehas no repeated vertices, the only vertices that lie in both paths are u and v. On the other hand, apath from u to v followed by a path from v to u is a cycle if the paths have no vertices in commonother than u and v.

Definition 5.8 Connected graph Let G = (V, E, ϕ) be a graph. If for any two distinctelements u and v of V there is a path P from u to v then G is a connected graph. If |V | = 1,then G is connected.

We make two observations about the definition.

• Because of Theorem 5.2, we can replace “path” in the definition by “walk” or “trail” if we wish.

• The last sentence in the definition is not really needed. To see this, suppose |V | = 1. Now G isconnected if, for any two distinct elements u and v of V , there is a path from u to v. This istrivially satisfied since we cannot find two distinct elements in the one element set V .

The graph of Figure 5.1 (p. 122) is not connected. (There is no path from EN to TM, forexample.) The subgraph of this graph induced by the edges {{SH, EN}, {EN, RL}, {EN, CS}} is aconnected graph with no cycles. Notice in Figure 5.1, that the relation defined on pairs of vertices u, vby“there exists a path from u to v” partitions the vertices into two subsets: V1 = {EN, SH, RL, CS}and V2 = {MN, SM, SE, TM}. Any two vertices in V1 can be joined by a path and the same is truefor any two vertices in V2. There is no path connecting a vertex in V1 to a vertex in V2.

This is the case in general for a graph G = (V, E, ϕ): The vertex set is partitioned into subsetsV1, V2, . . . , Vm such that if u and v are in the same subset then there is a path from u to v andif they are in different subsets there is no such path. The subgraphs G1 = (V1, E1, ϕ1), . . . , Gm =(Vm, Em, ϕm) induced by the sets V1, . . . , Vm are called the connected components of G. Every edgeof G appears in one of the connected components. To see this, suppose that {u, v} is an edge and

Page 14: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

134 Chapter 5 Basic Concepts in Graph Theory

note that the edge is a path from u to v and so u and v are in the same induced subgraph, Gi. Bythe definition of induced subgraph, {u, v} is in Gi.

*Example 5.7 Connected components as an equivalence relation If you’ve read Section 2,you may have realized that the definition of connected components is a bit sloppy: We need to knowthat the partitioning into such subsets can actually occur. To see that this is not trivially obvious,define two integers to be “connected” if they have a common factor. Thus 2 and 6 are connected and3 and 6 are connected, but 2 and 3 are not connected and so we cannot partition the set V = {2, 3, 6}into “connected components”. We must use some property of the definition of graphs and paths toshow that the partitioning of vertices is possible. One way to do this is to construct an equivalencerelation.

For u, v ∈ V , write u ∼ v if and only if either u = v or there is a walk from u to v. We will useTheorem 5.1 (p. 127) to prove that this is an equivalence relation. It is clear that ∼ is reflexive andsymmetric. We now prove that it is transitive. Let u ∼ v ∼ w. The walk from u to v followed bythe walk from v to w is a walk from u to w. This completes the proof that u ∼ v is an equivalencerelation. The relation partitions V into subsets V1, . . . , Vm.

Exercises

5.3.1. Let C be the set of courses at the university and S the set of students. Let V = C ∪ S and let{s, c} ∈ E if and only if student s is enrolled in course c.

(a) Prove that G = (V, E) is a simple graph.

(b) Prove that every cycle of G has an even number of edges.

5.3.2. A graph G = (V, E) is called bipartite if V can be partitioned into two sets A and B such that eachedge has one vertex in A and one vertex in B. (A partition means that A ∪B = V and A ∩B = ∅.)

(a) Prove that the example in Exercise 5.3.1 is a bipartite graph.

(b) Prove that every cycle in a bipartite graph has even length.

(c) Suppose that G is a connected bipartite graph. Develop an algorithm to partition the verticesof G into sets A and B such that each edge has one vertex in A and one vertex in B. Prove thatyour algorithm is correct.

(d) Extend your algorithm to all bipartite graphs.

(e) Prove that the number of ways to choose A and B in a bipartite graph with k connected

components is 2k.

*(f) Prove that a graph is bipartite if and only if every cycle in the graph has even length.

*5.3.3. A cut edge or isthmus of a connected graph G = (V, E,ϕ) is an edge e such that the removal of efrom G leaves a graph which is not connected. A cut vertex or articulation point of G is a vertex vsuch that the subgraph induced by V − {v} is not connected. For example, in Figure 5.2, edge g isan isthmus and vertex B is a cut vertex. For this problem, assume that G is simple.

(a) If e is a cut edge of G and v ∈ ϕ(e) is also on another edge f 6= e, prove that v is a cut vertexof G.

(b) Give an example of a connected graph that has a cut vertex but does not have an isthmus.

(c) Prove that an edge e of G is a cut edge if and only if it does not lie on a cycle.Hint. Look for a path that does not contain e but connects the two vertices in ϕ(e).

(d) (Challenge) Formulate and prove a result similar to the previous one for cut vertices.

Page 15: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

5.3 Paths and Subgraphs 135

5.3.4. A circuit (or “closed trail”) in a graph G = (V, E, ϕ) is defined exactly as is a cycle in Definition 5.7except that the “path with vertex sequence a1, . . . , an” is replaced by a “trail with vertex sequencea1, . . . , an.” In the next section, we’ll define a tree as a connected graph without cycles. Supposethat in this definition and in Definition 5.8 “path”is replaced by “trail” and “cycle” is replaced by“circuit.” Would the new definitions of tree and connected graph describe the same structures as theold definition? Explain.

5.3.5. We are going to describe a process for constructing a graph G = (V, E, ϕ) (with loops allowed). Startwith V = {v1} consisting of a single vertex and with E = ∅. Add an edge e1, with ϕ(e1) = {v1, v2},to E. If v1 = v2, we have a graph with one vertex and one edge, else we have a graph with twovertices and one edge. Keep track of the vertices and edges in the order added. Here (v1, v2) is thesequence of vertices in the order added and the (e1) is the sequence of edges in order added. Supposewe continue this process to construct a sequence of vertices (not necessarily distinct) added andsequence of distinct edges added. At the point where k distinct edges have been added, if v is the lastvertex added, then we add a new edge ek+1, different from all previous edges, with ϕ(ek+1) = {v, v′}

where either v′ is a vertex already added or a new vertex. Here is a picture of this process carriedout with the edges numbered in the order added, where the vertex sequence is

(A, A,B, E, D, A, B,F, G, E, C, C, G)

P ′(Q) :• • • • • • •A D E B F G C

2 9

5 4 3 7 8 12

6 10

111

Such a graph is called Eulerian or a “graph with an Eulerian trail.” By construction, if G is a graphwith an Eulerian trail, then there is a trail in G that includes every edge in G. If there is a circuit inG that includes every edge of G then G is called an Eulerian circuit graph or graph with an Euleriancircuit. Thinking about the above example, if a graph has an Eulerian trail but no Eulerian circuit,then all vertices of the graph have even degree except the start vertex and end vertex of the Euleriantrail (they have odd degree). If a graph has an Eulerian circuit then all vertices have even degree.The converses in each case are also true (but take a little work to show). In each of the followinggraphs, find the longest trail (most edges) and longest circuit. If the graph has an Eulerian circuit ortrail, say so.

(a)

• •

• •A

D

e

B

C

f

a

b

c d

(b)

• • •

• • •A

B

e

C

D

f

F

E

k

a g

b h

c d i j

(c)

• • •

• • •A

B

e

C

D

f

F

E

k

a g

b h

c d i j

n

m

(d)

• • •

• • •A

B

e

C

D

F

E

k

a g

b h

c d i j

n

m

Page 16: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

136 Chapter 5 Basic Concepts in Graph Theory

5.3.6. Suppose we start with a graph G′ = (V, E′, ϕ′) that is a cycle and then add additional edges, withoutadding any new vertices, to obtain a graph G = (V, E, ϕ). As an example, consider

•a

b

c

de

f

C

D

E

B

A

F

•a

b

c

de

f

C

D

E

B

A

F

i

h

g

e

where the first graph G′ = (V, E′, ϕ′) is the cycle induced by the edges {a, b, c, d, e, f}. A graph that

can be constructed from such a two-step process is called a Hamiltonian graph. The cycle G′ iscalled a Hamiltonian cycle. Alternatively, a cycle in a graph G = (V, E, ϕ) is a Hamiltonian cyclefor G if every element of V is a vertex of the cycle. A graph G = (V, E, ϕ) is Hamiltonian if it hasa subgraph that is a Hamiltonian cycle for G. For each of the following graphs G = (V, E, ϕ), find acycle in G of maximum length. State whether or not the graph is Hamiltonian.

(a)

••

••

AB

C

DE

F

G

H

••

••

IJ

K

LM

N

O

P

(b) • • •

• • •

A B C

D E F

(c)

••

••

AB

C

DE

F

G

H

••

••

IJ

K

LM

N

O

P• • •

• • •

Q R S

T U V

(d)

••

••

AB

C

DE

F

G

H

••

••

IJ

K

LM

N

O

P• • •

• • •

Q R S

T U V

5.4 Trees

Trees play an important role in a variety of algorithms. We have already met decision trees inChapter 3. In this section, we define trees precisely and look at some of their properties. We studytrees further in Section 6.1 and Chapter 9.

Definition 5.9 (Free) Tree If G is a connected graph without any cycles then G is calleda tree. (If |V | = 1, then G is connected and hence is a tree.) A tree is also called a free tree.

Page 17: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

5.4 Trees 137

The graph of Figure 5.2 (p. 123) is connected but is not a tree. The subgraph of this graph inducedby the edges {a, e, g} is a tree. If G is a tree, then ϕ is an injection since if e1 6= e2 and ϕ(e1) = ϕ(e2),then {e1, e2} induces a cycle. Because of this, we can think of a tree as a simple graph when we arenot interested in names of the edges.

It’s natural to ask how many trees can be formed using an n-set V for the vertices. In Exam-ple 5.10 (p. 143), we’ll prove that the answer is nn−2. Another proof is given in Exercise 5.4.12.

Since the notion of a tree is so important, it will be useful to have some equivalent definitionsof a tree. We state them as a theorem

Theorem 5.4 Definitions of tree If G is a connected graph, the following are equivalent.

(a) G is a tree.

(b) G has no cycles.

(c) For every pair of vertices u 6= v in G, there is exactly one path from u to v.

(d) Removing any edge from G gives a graph which is not connected.

(e) The number of vertices of G is one more than the number of edges of G.

Proof: By the definition of a tree, (a) and (b) are equivalent.

Theorem 5.3 can be used to prove that (b) and (c) are equivalent. We leave that as an exercise.

If {u, v} is an edge, it follows from (c) that the edge is the only path from u to v and soremoving it disconnects the graph. Hence (c) implies (d). We leave it as an exercise to prove that

(d) implies (b). This shows that (a), (b), (c), and (d) are all equivalent.

All that remains is (e).

We first show that (b) implies (e). We will use induction on the number of vertices of G. If Ghas one vertex, it has no edges and so we are done. Otherwise, we claim that G has a vertex u of

degree 1; that is, it lies on only one edge {u, w}. We prove this claim shortly. Remove u and {u, v}to obtain a graph H with one less edge and one less vertex. Since G is connected and has no cycles,the same is true of H . Since H has fewer vertices than G, the induction hypothesis tells us that (e)

is true for H : there is one more vertex than edge in H . Since H was obtained from G by removingone edge and one vertex, (e) is true for G. It remains to prove the existence of u. Suppose no suchu exists; that is, suppose that each vertex lies on at least two edges. We will derive a contradiction.Start at any vertex v1 of G leave v1 by some edge e1 to reach another vertex v2. Leave v2 by some

edge e2 different from the edge used to reach v2. Continue with this process. Since each vertex lieson at least two edges, the process never stops. Hence we eventually repeat a vertex, say

v1, e1, v2, . . . , vk, ek, . . . , vn, en, vn+1 = vk.

The edges ek, . . . , en form a cycle, which is a contradiction.

Now suppose G is a connected graph which is not a tree. It suffices to prove that G has at leastas many edges as it has vertices. Why? If we do so, we will have shown

((a) is false) implies ((e) is false)

and hence the contrapositive ((e) is true) implies ((a) is true). On with the proof! By (d) we can

remove an edge from G to get a new graph which is still connected. If this is not a tree, repeat theprocess and keep doing so until we reach a tree. Since (a) implies (b) and (b) implies (e), the numberof vertices is now one more than the number of edges. Since we removed edges from G but did notremove vertices, G must have at least as many edges as vertices.

Page 18: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

138 Chapter 5 Basic Concepts in Graph Theory

Example 5.8 Symmetry in graphs and trees Let G = (V, E) be a simple graph. Supposeν : V → V is a isomorphism of G to G. Graph isomorphism is defined in Definition 5.4 (p. 128). Wecall an isomorphism from something to itself an “endomorphism” or a “symmetry.” How much cana symmetry move the vertices of a graph?

It turns out that most graphs have only the trivial endomorphism ν(v) = v for all v ∈ V , sothe vertices can’t move at all. On the other hand, if the graph has no edges (E = ∅) or all possibleedges (E = P2(V )), then every permutation of the vertices in V is a symmetry since the condition{u, v} ∈ E if and only if {ν(u), ν(v)} ∈ E in Definition 5.4 is easily seen to hold. What about graphsthat are encountered in practice?

The most common graphs in computer science are trees. Most trees have symmetries. For ex-ample, suppose {u, v}, {u, w} ∈ E and v and w are leaves in a tree T = (V, E). (Note that V mayhave many more vertices besides u, v and w.) We leave it for you to verify that

ν(x) =

{

w, if x = v,v, if x = w,x, otherwise,

is an isomorphism of T . Only the vertices v and w moved. While all vertices might move in anisomorphism of a tree, there are always some that either don’t move or don’t move “far.” We’llprove

Theorem 5.5 If ν is an isomorphism of the tree T = (V, E) then either

(a) there is a vertex v with ν(v) = v or

(b) there is an edge {u, v} with ν(u) = v and ν(v) = u.

In other words, either a vertex or an edge does not move.

Suppose (a) is not true. We’ll define a map f : V → E and use the Pigeonhole Principle,Theorem 2.5 (p. 55).

If x ∈ V , ν(x) 6= x. Since T is a tree, there is a unique path from x to ν(x). Let f(x) be thefirst edge on the path. Since |E| = |V | − 1, the Pigeonhole Principle tells us that there must be twovertices v1 and v2 with f(v1) = f(v2). Thus v1 and v2 are the ends of an edge e = {v1, v2}. Since νis an isomorphism, ν(e) = {ν(v1), ν(v2)} is also an edge.

We claim ν(e) = e. Draw a picture and try to understand why this is so. (Remember that pathsbetween tree vertices are unique.)

∗ ∗ ∗ Stop and think about this! ∗ ∗ ∗

If ν(e) 6= e, here is a way to get from v1 to v2 without using e. There is a path Pi from vi to ν(vi)that starts with the edge e. Start at v1 and follow the part of P2 after e to ν(v1). Traverse the edgeν(e) = {ν(v1), ν(v2)} from ν(v1) to ν(v2). Since e = {v1, v2} is the first edge on P2, you can followP1 backwards until you reach v2. You have just walked from v1 to v2 without using e. Thus there isa path from v1 to v2 that does not use e. Since there can be only one path from v1 to v2, namely e,our assumption that ν(e) 6= e must be wrong. Defining u = v1 and v = v2 completes the proof.

The decision trees in Chapter 3 have some special properties. First, they have a starting point.Second, the edges (decisions) out of each vertex are ordered. We now formalize these concepts.

Definition 5.10 Rooted graph A pair (G, v), consisting of a graph G and a specified vertexv, is called a rooted graph with root v.

A rooted tree is sometimes simply referred to as a tree, but we will never do so.

Page 19: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

5.4 Trees 139

a

b c d

e f

j k l

g h i

Figure 5.5 A rooted plane tree with root a at the top, as usual. Linear ordering of siblings is left to right.

Definition 5.11 Parent, child, sibling and leaf Let (T, r) be a rooted tree. If w is anyvertex other than r, let r = v0, v1, . . . , vk, vk+1 = w, be the unique path from r to w. We call vk

the parent of w and call w a child of vk. Vertices with the same parent are siblings. A vertexwith no children is a leaf.

Definition 5.12 Rooted plane tree Let (T, r) be a rooted tree. For each vertex, order thechildren of the vertex. The result is a rooted plane tree, which we abbreviate to RP-tree.An RP-tree is also called a tree. Parents and children are also called fathers and sons.

Figure 5.5 shows an RP-tree. The sons of b are e and f , the parent of g is d, vertex k has no children,and the siblings of h are g and i. The decision trees of Chapter 3 are RP-trees. When we draw atree as in Figure 5.5, the root is normally the topmost vertex and all edges are directed downward.In addition, siblings are drawn from left to right following their ordering. For example, the orderingof the siblings {j, l, k} is j, then k and then l.

It’s clear where “rooted” comes from in RP-tree, but where does “plane” come from? Whensuch a tree is drawn on a piece of paper (a plane), we can start with the root, list its children belowit in order, and so on—just like the picture of a decision tree. On the other hand, any rooted treedrawn in the plane has a natural ordering for the children of a vertex v provided v is not the root:Starting at the edge from the parent of v, walk counterclockwise around v, listing the children of vin the order in which their edges are met.

We now have two different concepts that are referred to as trees: free trees (Defi-nition 5.9) and RP-trees. How will we keep them straight? When we believe thereis no chance of confusion, we may call them trees; otherwise will we call them freetrees and RP-trees. Sometimes the distinction is not needed. For example, by Theo-rem 5.4 the statement that a tree has no cycles applies equally well to RP-trees andfree trees since every RP-tree is simply a free tree with a root and orderings.

In Chapter 9 we’ll discuss some recursive aspects of RP-trees including tree traversal and gram-mars.

Exercises

5.4.1. Complete the proof of Theorem 5.4.

5.4.2. Let G = (V, E, ϕ) be a connected graph. Using Theorem 5.4 and its proof, do the following.

(a) Prove that G has a cycle if and only if there is some edge e such that the subgraph of G withvertices V and edges E − {e} is connected.

(b) Prove that there is a subgraph of G which is a tree and has vertex set V . Such a tree is called aspanning tree.

(c) Prove that |V | ≤ |E|+ 1 with equality if and only if G is a tree.

Page 20: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

140 Chapter 5 Basic Concepts in Graph Theory

5.4.3. Let T = (V, E) be a tree and let d(v) be the degree of a vertex as defined in Exercise 5.1.1.

(a) Prove that∑

v∈V(2− d(v)) = 2.

Hint. See Exercise 5.1.1.

(b) Prove that, if T has a vertex of degree m ≥ 2, then it has at least m vertices of degree 1. Verticesof degree 1 are called leaves or terminal vertices.

(c) Give an example for all m ≥ 2 of a tree with a vertex of degree m and only m leaves.

(d) Suppose that T has at most one vertex of degree 2. Prove that over half the vertices of T areleaves.

(e) Give an example for all m > 0 of a tree with m leaves, m − 1 other vertices and at most onevertex of degree 2.

5.4.4. In this exercise, we study how counting edges and vertices in a graph can establish that cycles exist.

(a) Using induction on n, prove:If n ≥ 0, a connected graph with v vertices and v + n edges has at least n + 1 cycles.

(b) Prove that a graph with v vertices, e edges and c components has at least c + e− v cycles.Hint. Use (a) for each component.

(c) Show that (a) is best possible, even for simple graphs. In other words, for each n construct asimple graph that has n more edges than vertices but has only n + 1 cycles.

5.4.5. Prove that every tree with at least 3 vertices has a cut vertex and a cut edge. (The terms cut edgeand cut vertex are defined in Exercise 5.3.3.)

5.4.6. Give an example of a graph that satisfies the specified condition or show that no such graph exists.

(a) A tree with six vertices and six edges

(b) A tree with three or more vertices, two vertices of degree one and all the other vertices withdegree three or more.

(c) A disconnected simple graph with 10 vertices, 8 edges and a cycle.

(d) A disconnected simple graph with 12 vertices, 11 edges and no cycles.

(e) A tree with 6 vertices and the sum of the degrees of all vertices 12.

(f) A connected simple graph with 6 edges, 4 vertices, and exactly 2 cycles.

(g) A simple graph with 6 vertices, 6 edges and no cycles.

5.4.7. The height of a rooted tree is the the length of the longest path from a leaf of the tree to the rootof the tree. A rooted tree in which each non-leaf vertex has at most two children is called a binary

tree. If each non-leaf vertex has exactly two children, the tree is called a full binary tree.

(a) Show that if a binary tree has l leaves and height h then l ≤ 2h, or, equivalently, log2(l) ≤ h.

(b) Given that a binary tree has l leaves, what can you say about the maximum value of h?

(c) Given a full binary tree with l leaves, what is the maximum height h?

(d) Given a full binary tree with l leaves, what is the minimum height h?

(e) Given a binary tree of l leaves, what is the minimal height h?

5.4.8. Prove that a full binary tree with n leaves has a total of 2n−1 vertices. (The concept of a full binarytree was defined in Exercise 5.4.7.)Challenge. How many different proofs can you find?

5.4.9. In each of the following cases, state whether or not such a tree is possible.

(a) A binary tree with 35 leaves and height 100.

(b) A full binary tree with 21 leaves and height 21.

(c) A binary tree with 33 leaves and height 5.

(d) A full binary tree with 65 leaves and height 6.

5.4.10. What is the maximal number of vertices in a rooted tree of height h if every vertex has at most kchildren. What is the maximal number of leaves in a rooted tree of height h if every vertex has atmost k children?

Page 21: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

5.5 Directed Graphs (Digraphs) 141

5.4.11. We are going to define certain important lists of vertices associated with the rooted plane tree,Figure 5.5. These lists can, in a similar fashion, be associated with any rooted plane tree. The firstlist is abcdefghijkl. This list, called the breadth-first vertex list, is obtained by starting at the rootand reading the vertices of the tree, left to right, as one would read a book. For this definition towork on any tree, you must imagine the tree drawn with the root at the top and all vertices distanceone from the root drawn at the next level down, all of distance two at the next level, etc. Thesecond important list is called the depth-first vertex list. The depth-first vertex list for Figure 5.5is abebfjfkflfbacadgdhdida. Note that each vertex appears in the depth-first vertex list a numberof times equal to one plus the number of children of that vertex. If one extracts the sublist of firstoccurrences of each vertex in the depth first list, one gets the list abefjklcdghi. This list is called thepre-order vertex list. If one extracts the sublist of last occurrences of each vertex in the depth firstlist, one gets the list ejklfbcghida This list is called the post-order vertex list.

(a) For the following rooted plane tree, list the breadth-first, depth-first, pre-order, and post-ordervertex lists.

• • •

• • • • •

• • • •

A

BC

D

E

F G

H

I J K

L

M

(b) Given that the following is the depth-first vertex list of a rooted plane tree, reconstruct the tree:MKBKLKMIHDHGHFHIEICIM .

(c) Is it possible to reconstruct a rooted plane tree given just its pre-order vertex list?

(d) Is it possible to reconstruct a rooted plane tree given its pre-order vertex list and its post-ordervertex list?

*5.4.12. Construct a bijection between functions from n− 2 to n and trees with V = n as follows. Repeatedlyremove the leaf with the largest label from the tree until only a two vertex tree remains. When a leafis removed, list the vertex that it was attached to. This is called the Prufer sequence for the tree. Toestablish the bijection, you must prove that any list of length n − 2 chosen from n with repetitionallowed corresponds is the Prufer sequence of a tree.Hint. Show that the largest number not in the Prufer sequence is the vertex that was first removed.

5.5 Directed Graphs (Digraphs)

In the next two sections, we take a look at two important modifications of the concept of a graph.Look again at Figure 5.2 (p. 123). Imagine now that the symbols a, b, c, d, e, f and g, instead

of standing for route names, stand for commodities (applesauce, bread, computers, etc.) that areproduced in one town and shipped to another town. In order to get a picture of the flow of com-modities, we need to know the directions in which they are shipped. This information is providedby Figure 5.6.

In set theoretic terms, the information needed to construct Figure 5.6 can be specified by givinga pair D = (V, ϕ) where ϕ is a function with domain E = {a, b, c, d, e, f, g} and range V × V .Specifically,

ϕ =(

a b c d e f g

(B,A) (A,B) (C,A) (C,B) (B,C) (C,B) (D,B)

)

.

The structure given in Figure 5.6 is an example of a directed graph:

Page 22: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

142 Chapter 5 Basic Concepts in Graph Theory

•A •B

•C

•D

g

c

e

b

a

d

f

Figure 5.6 Cities with flow of commodities shown.

Definition 5.13 Directed graph A directed graph (or digraph) is a triple D = (V, E, ϕ)where V and E are finite sets and ϕ is a function with domain E and range V × V . We call Ethe set of edges of the digraph D and call V the set of vertices of D.

Note that it is possible that f(x) = (v, v) for v ∈ V . Such an edge x is called a loop. A simpledigraph, like a simple graph, is a pair (V, E) where E ⊆ V × V . Subgraphs, paths, walks, trails andcycles in directed graphs are analogous to the corresponding structures in a graph. A directed graphD′ = (V ′, E′, ϕ′) is a directed subgraph of D = (V, E, ϕ) if V ′ ⊆ V , E′ ⊆ E and ϕ′ is the restrictionof ϕ to E′ with range V ′ × V ′. A directed path in the digraph D = (V, E, ϕ) is a sequence of edgese1, . . . , en−1 for which there is a sequence of distinct vertices a1, . . . , an such that ϕ(ei) = (ai, ai+1)for i = 1, 2, . . . , n − 1. The subdigraph induced by a set of edges E′ ⊆ E or the set of verticesV ′ ⊆ V is defined in a way analogous to the corresponding concept for graphs. Let D = (V, E, ϕ)be a directed graph and let e1, . . . , en−1 with vertex sequence a1, . . . , an be a directed path. If x isan edge of D such that ϕ(x) = (an, a1), then the subgraph induced by the edges {e1, . . . , en−1, x} iscalled a directed cycle in D. For example, the subgraph induced by the edges {c, b, e} is a directedcycle in the digraph of Figure 5.6. The notions of edge labeling and vertex labeling extend directly todigraphs. The ideas of connected components and trees are more complicated in digraphs.

Example 5.9 Digraphs and binary relations Simple digraphs appear in mathematics underanother important guise: binary relations. A binary relation on a set V is simply a subset of V × V .Often the name of the relation and the subset are the same. Thus we speak of the binary relationE ⊆ V × V . If you have absorbed all the terminology, you should be able to see immediately that(V, E) is a simple digraph and that any simple digraph (V ′, E′) corresponds to a binary relationE′ ⊆ V ′ × V ′.

What about simple graphs? We can identify {u, v} ∈ P2(V ) with (u, v) ∈ V × V and with(v, u) ∈ V × V . A binary relation R is called “symmetric” if (u, v) ∈ R implies (v, u) ∈ R. Thusit seems that simple graphs correspond to symmetric binary relations. This is not quite true since(u, u) would correspond to a loop. We must either allow loops or only look at symmetric binaryrelations that do not contain (u, u).

An equivalence relation on a set S is also a binary relation R ⊆ S×S: We have (x, y) ∈ R if andonly if x and y are equivalent. Note that this is a symmetric relationship. Which simple graphs (withloops allowed) correspond to equivalence relations? There is a simple description of them. We’ll letyou look for it.

Functions from a set to itself are another special case of binary relations. Figure 5.7 shows afunction and its associated digraph, called a functional digraph. Notice that some of the verticesform cycles and the remaining vertices form trees that are attached to the cycles, each tree being

Page 23: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

5.5 Directed Graphs (Digraphs) 143

6

4 78

1 2 9

3 5

Figure 5.7 The functional digraph associated with the function ϕ =(

1 2 3 4 5 6 7 8 96 6 3 7 3 4 6 4 2

)

.

6473

5 8 1

2 9

Figure 5.8 The doubly marked digraph built from the functional digraph of Figure 5.7. Removing thearrows gives a doubly marked tree.

attached by one of the vertices on a cycle. For example, the vertices 1, 2, 6, and 9 form a tree thatis attached to a cycle by the vertex 6.

One can easily read powers (using composition, not multiplication) of a function from the func-

tional digraph: The function itself comes from directed paths of length 1 and ϕk comes from directedpaths of length k.

Permutations are a special case of functions. You should be able to see that, in this case, thefunctional digraph consists of cycles with no trees attached.

Example 5.10 The number of labeled trees Let tn be the number of trees with vertex setn. It’s not hard to draw the possible trees for small values of n. If you do this, you should discoverthat t1 = 1, t2 = 1, t3 = 3 and t4 = 16. What is the pattern?

It turns out that tn = nn−2. You might try to check this for t5 = 125. How can we prove thisformula?

When we know the answer to a problem, we can often use some backwards reasoning or “answeranalysis” to figure out how we might solve the problem. Since nn−2 is the number of functionsfrom n − 2 to n, we might try to find a bijection between such functions and trees. (This is done inExercise 5.4.12.) Unfortunately, it is not at all clear how to proceed with this idea.

It would be much nicer if we looked at functions from n to n because these lead to functionaldigraphs: with the function f ∈ nn, we associate the functional digraph (V, E) where V = n andE = {(x, f(x)) |x ∈ n}. Let’s pursue this and see if we can generate some ideas.

Look at the functional digraph in Figure 5.7. If we could somehow get rid of the cycles, we wouldhave trees!

Some inspiration is needed. Here it is. The vertices on the cycles are a permutation drawn incyclic form. For example, in Figure 5.7, the permutation is (3)(4, 7, 6). Maybe we can draw thepermutation in some other fashion. We can also write permutations in two line or one line form:

(

3 4 6 73 7 4 6

)

3, 7, 4, 6.

We could simply take the one line form and construct a directed graph from it:

3 7 4 6

We could also drag along the other vertices that form trees attached to these cyclic vertices. This isshown in Figure 5.8, where you should ignore the circles around the vertices for the time being. Wehave constructed a tree!

This has one problem, we can no longer tell which vertices were on the cycles. The circles inFigure 5.8 take care of this, the double circle indicating the start of one line form and the single

Page 24: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

144 Chapter 5 Basic Concepts in Graph Theory

circle indicating the end. The unique path from the end to the start gives the one line notation,written in reverse. (The directed path is unique because we have constructed a tree.)

Actually our picture has more information than we need: The direction of the edges is determinedby the fact that they are all directed toward the root, which is 3 in our example. Thus we can erasethe arrowheads on the edges with no loss of information.

This entire process is reversible—Given any tree on n in which one vertex is marked with adouble circle and one with a single circle, we can recover a unique function which gives this markedtree. Note that the same vertex may have the double circle and the single circle. This happens whenthere is only one point of the functional digraph on cycles. How many such doubly marked trees arethere? By the bijection, there are nn. Since we form a tree AND mark a vertex with a double circleAND mark a vertex with a single circle, the number is also tn ×n×n. This completes the proof.

Exercises

5.5.1. If D = (V, ϕ) is a loopless directed graph, the associated graph G(D) is obtained by removing thedirections of the edges. Instead of this rough geometric description, give a definition in terms of setsand functions.Hint. Define a function with domain {(x, y) | x, y ∈ V and x 6= y}.

5.5.2. We are interested in the number of simple digraphs with V = n.

(a) Find the number of them.

(b) Find the number of them with no loops.

(c) In both cases, find the number of them with exactly q edges.

5.5.3. An oriented simple graph is a simple graph which has been converted to a digraph by assigning anorientation to each edge. The orientation of {u, v} can be thought of as a mapping of it to either(u, v) or (v, u). Give an example of a simple digraph that has no loops but is not an oriented simplegraph

5.5.4. We are interested in the oriented simple graphs with V = n. (They are defined in Exercise 5.5.3.)

(a) Find the number of them.

(b) Find the number of them with exactly q edges.

5.5.5. Define an equivalence relation on digraphs that allows you to introduce the notion of unlabeleddigraphs. Prove that you have, in fact, defined an equivalence relation.

5.5.6. A digraph is strongly connected if, for every two vertices v and w there is a directed path from vto w. From any digraph D, we can construct a simple graph S(D) on the same set of vertices byletting {v, w} be an edge of S(D) if and only if at least one of (u, v) and (v, u) is an edge of D. Youshould find the first three parts of this exercise easy, if you understand the meaning of the variousconcepts—strongly connected, path, S(D), etc.

(a) Prove that, if D is strongly connected, then S(D) is connected.

(b) Construct an example of a digraph D such that D is not strongly connected but S(D) is con-nected.

(c) Suppose that V1, V2 is a partition of the vertices V of a strongly connected digraph D; that is,V1 6= ∅, V2 6= ∅, V1 ∪ V2 = V , and V1 ∩ V2 = ∅. Prove that in D there is an edge from V1 to V2

and an edge from V2 to V1. (This means that for some v1, w1 ∈ V1 and v2, w2 ∈ V2, both (v1, v2)and (w2, w1) are edges of D.) We will call such a partition of V “2-way joined.”

(d) Suppose that every partition V1, V2 of the vertices of D is 2-way joined. Prove that D is stronglyconnected.

Page 25: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

5.5 Directed Graphs (Digraphs) 145

5.5.7. Suppose that we are given a set of statements, for example (a) through (e) in Theorem 5.4, and thatwe have proved that some statements imply others. Construct a directed graph D as follows. Thestatements are the vertices V of D. For statements v and w, (v,w) is an edge of D if and only if wehave a proof that statement v implies statement w. Prove the claim: “If D is strongly connected, wehave proved enough to show that the statements in V are all equivalent.” (See Exercise 5.5.6 for adefinition of strongly connected.)

5.5.8. For any subset U of the vertices V of a directed graph D, define din(U) to be the number of edgesof e of D with ϕ(e) of the form (w, u) where u ∈ U and w 6∈ U . Define dout(U) similarly.

(a) For v a single vertex, what is din({v}) in terms of the picture of D?

(b) Prove that∑

din({v}) =∑

dout({v}), where the sums both range over all v ∈ V .

(c) Prove that∑

u∈Udin({u}) equals din(U) plus the number of non-loop edges of D that have both

of their endpoints in U .

(d) Suppose that din({v}) = dout({v}) for all v ∈ V . Prove that din(U) = dout(U) for allU ⊆ V .

5.5.9. Use the notation of Exercise 5.5.8. Suppose din({v}) = dout({v}) for all v ∈ V . Prove that for everyedge e of D there is a directed cycle in D that contains e.

5.5.10. Suppose that S(D) is connected, where S(D) is obtained from D by removing the directions of theedges. Use the notation of Exercise 5.5.8. Suppose din({v}) = dout({v}) for all v ∈ V . Prove thatthere is a directed trail that contains every edge of D. Such a trail is called an Eulerian trail.

5.5.11. Let G be a connected simple graph.

(a) Suppose that the edges of G can be directed so that the resulting digraph is strongly connected.Prove that G has no isthmuses.

*(b) Suppose that G has no isthmuses. Prove that the edges of G can be directed so that the resultinggraph is strongly connected. (This seems to be quite difficult given the material you have hadso far. We will return to it later.)

5.5.12. Let R ⊆ S × S be a binary relation on S. Suppose that |S| = n.

(a) How many reflexive binary relations R are there on S?

(b) How many reflexive and symmetric relations R are there on S?

(c) The relation S is unreflexive if for all x ∈ S, (x, x) /∈ R. How many unreflexive, symmetric binaryrelations R are there on S?

(d) How many symmetric relations R on S are not reflexive?

5.5.13. A binary relation R on S is an order relation if it is reflexive, antisymmetric, and transitive. R isantisymmetric if for all (x, y) ∈ R with x 6= y, (y, x) /∈ R. Given an order relation R, the covering

relation H of R consists of all (x, z) ∈ R such that there is no y, x < y < z, where (x, y) ∈ R. Apictorial representation of the covering relation as a directed graph is called a “Hasse diagram” of H .

(a) Show that the divides relation on S = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} is an orderrelation. By definition, (x, y) is in the divides relation on S is x is a factor of y. Thus, (4, 12) isin the divides relation. x|y is the usual notation for x is a factor of y.

(b) Draw the directed graph of the covering relation of R.

5.5.14. Let R be a binary relation on S. Let TR be the smallest transitive relation, R ⊆ TR. By “smallest”we mean that if R ⊆ N ⊂ TR then N is not transitive. In other words, there is no proper subset ofTR that contains R and is transitive. Note that if R is already transitive then TR = R. TR is calledthe transitive closure of R. Let S = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} and let

H = {(2, 4), (2, 6), (2, 10), (2, 14), (3, 6), (3, 9), (3, 15), (4, 8), (4, 12), (5, 10), (5, 15), (6, 12), (7, 14)}.

Find the transitive closure of H .

Page 26: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

146 Chapter 5 Basic Concepts in Graph Theory

5.5.15. A graph is selected uniformly at random from all q-edge simple graphs with vertex set n.

(a) What is the probability that the graph we have chosen is a tree? (Your answer will dependon q.)

(b) Show that this probability is bigger than (2/e)n−1/n when q = n− 1.

Hint. You may use the fact that, by Stirling’s formula, (n − 1)! >(

n−1e

)n−1. Also note that

(

Nq

)

< Nq/q!.

*5.6 Computer Representations of Graphs

What is the best way to represent a graph in a computer? That question is based on the mistakenassumption that there is one best way. In fact, there are a variety of ways to represent a graph.We’ll briefly discuss two common ones: adjacency lists and matrices. For simplicity, we will limit ourattention to simple graphs and digraphs.

Let G = (V, E) be a graph. For each v ∈ V , keep a list of those x ∈ V such that {v, x} ∈ E.This is a relatively compact method for storing the structure of G. The actual implementation maybe with an array or with a linked list. If D = (V, E) is a simple digraph, then we keep two lists foreach v ∈ V ; one of those x ∈ V such that (x, v) ∈ E and one of those y ∈ V such that (v, y) ∈ E.

The method of linked lists is usually used with RP-trees. If the number of possible sons a vertexcan have is not limited, a variation of this method is frequently used. Here’s one such variation. Eachvertex v has a list of four vertices. If a vertex needed in the list does not exist, that fact is recordedin the list (e.g., by using zero). The four vertices are:

• the parent f of the vertex v;

• the first child of v in the ordering of the children of v;

• the sibling of v that immediately precedes it in the ordering of the siblings of v;

• the sibling of v that immediately follows it in the ordering of the siblings of v.

Matrices are simply doubly indexed arrays. In the most common representation of a simplegraph G = (n, E), the matrix A(G) is n × n and

ai,j ={

1 if {i, j} ∈ E;0 otherwise.

For a simple digraph D = (n, E), we make a minor adjustment to define A(D):

ai,j ={

1 if (i, j) ∈ E;0 otherwise.

This representation can waste a considerable amount of space if the graph has relatively few edges. Inany event, only about half of A(G) is needed since ai,j = aj,i. The matrix representation is useful forsome calculations of numbers related to the structure of the graph. See, for example, Exercise 5.6.3.

Exercises

5.6.1. Suppose that G is a bipartite simple graph. (See Exercise 5.3.2 for a definition.) Prove that thevertices can be numbered 1 through n = |V | such that for some k the matrix A(G) has a k× k blockof zeroes in its upper left corner and an (n−k)×(n−k) block of zeroes in its lower right corner.

5.6.2. Suppose that G is a simple graph with connected components G1, . . . , Gm. Number the vertices of Gby first numbering those in G1, then those in G2 and so on. Suppose that Gi has ni vertices. Providea description of A(G) like that in Exercise 5.6.1.

Page 27: Basic Conceptsin Graph Theory - UCSD Mathematics …math.ucsd.edu/~ebender/CombText/ch-5.pdf · Basic Concepts in Graph Theory Introduction ... The set V is represented clearly in

Notes and References 147

5.6.3. This exercise requires familiarity with matrix multiplication. Let G = (n, E) be a simple graph. Let

a(k)i,j be the (i, j) element of the matrix (A(G))k. Define a walk from i to j like a path, but allow

repetitions; i.e., a walk is a sequence e1, e2, . . . , en−1 and a sequence of v1, . . . , vn of vertices suchthat v1 = i, vn = j and ϕ(ei) = {vi, vi+1}. The length of the walk is n − 1, the number of edges itcontains, with repetitions counted.

(a) Prove that there is a walk of length k from i to j in G if and only if a(k)i,j 6= 0.

(b) Suppose that i 6= j. If a(k)i,j 6= 0 for some k > 0, let m be the smallest such k. Prove that there is

a path of length m between i and j.

(c) Can you find an analog of the previous result for cycles? Be careful!

(d) Prove that G is connected if and only if (A(G) + I)k contains no zeroes for all sufficiently largek. Prove that all k ≥ n− 1 are sufficiently large.

Hint. With B = A(G) + I and A(G)0 = I , prove that b(k)i,j =

∑kt=0

(

kt

)

a(t)i,j .

5.6.4. State and prove results like those in the previous exercise for directed simple graphs.

5.6.5. A matrix is called nilpotent if all sufficiently high powers of it consist entirely of zeroes. Find necessaryand sufficient conditions on a simple digraph D for A(D) to be nilpotent.

Notes and References

Because of the relatively modest mathematical prerequisites and the range of applications of graphtheory, introductory texts range from high school level to graduate school level and from very appliedto very theoretical. Even within one of these compartments, the breadth of graph theory results ina diversity of viewpoints. This is illustrated by the variety in the references.

The book by Ore and Wilson [10] is a delightful elementary introduction. The books by Berge [1],Bondy and Murty [3], Chartrand and Lesniak [4] and Tutte [12] are more advanced than our text.The remaining books are at a level similar to our text, although they often contain some moreadvanced topics. If you are particularly interested in applications, see the book by Roberts [11]. Ifyour are interested in algorithms, see the book by McHugh [8].

Other applications of the Pigeonhole Principle to prove properties of trees can be found in [7].Other proofs of the formula tn = nn−2 for trees can be found in Moon’s article [9].

1. Claude Berge, The Theory of Graphs and Its Applications, Dover (2001).

2. Bela Bollabas, Graph Theory: An Introductory Course, Springer-Verlag (1971).

3. J. Adrian Bondy and U.S.R. Murty, Graph Theory with Applications, American Elsevier (1976).

4. Gary Chartrand and Linda Lesniak, Graphs and Digraphs, 4th ed., CRC Press (2004).

5. Alan Gibbons, Algorithmic Graph Theory, Cambridge Univ. Press (1985).

6. Ronald J. Gould and Ron Gould, Graph Theory, Bejamin Cummings (1988).

7. N. Graham, R.C. Entringer and L.A. Szekely, New tricks for old trees: Maps and the PigeonholePrinciple, Amer. Math. Monthly 101 (1994) 664–667.

8. James A. McHugh, Algorithmic Graph Theory, Prentice-Hall (1990).

9. John W. Moon, Various proofs of Cayley’s formula for counting trees, in Frank Harary (ed.), ASeminar on Graph Theory, Holt, Rinehart and Winston (1967).

10. Oystein Ore and Robin J. Wilson, Graphs and Their Uses, Mathematical Assn. of America(1990).

11. Fred S. Roberts, Applied Combinatorics, Prentice-Hall (1984).

12. William T. Tutte, Graph Theory, Encyclopedia of Mathematics and Its Applications, Vol. 21,Cambridge Univ. Press (1984).