If the edges in a graph represent connections, it is obvious to ask whether as a whole is “connected”. There are two seemingly different ways of making this precise; today we introduce these and show that they are the same.

It may be easiest to define what it means for a graph to be disconnected.

Definition: Disjoint union

Given two graphs and , the disjoint union is obtained by taking the disjoint union of both the vertices and edges of and . So consists of a copy of and a copy of , with no edges in between the two graphs.

Definition: Disconnected

A graph is disconnected if we can write for two proper (i.e., not all of ) subgraphs and .

It then makes sense to say that is connected if it is not disconnected. However, the more intuitive notion of being connected is that “you can get from any vertex to any other”, which we now make precise.

Walks, Trails, Paths

Definition

A walk in a graph is a sequence

where

  • the are vertices
  • the are edges
  • edge goes between vertices and

Note that, when the graph does not have multiple edges, it is enough to record just the , but if has multiple edges that just knowing the vertices does not determine the walk.

We say that the walk is between vertices and if to vertex . Thus, it is natural to say that a graph is connected if there is a walk between any two vertices . We now show that this agrees with our previous definition of connected.

Lemma

The following are equivalent:

  1. is connected.
  2. There is a walk between any two vertices

Proof

1 implies 2: Supppose that is connected, and let ; we want to show that there is a walk from to .

Define to be the set of all vertices so that there is a walk from to ; we want to show that .

First, observe that there are no edges from to . Suppose that was an edge between and . Since , by the definition of there is a walk from to . We can add the edge to the end of the walk, to get a walk from to , and hence by definition .

Now suppose that . Then and are both nonempty, and by the above there are no edges between them, and so is not connected, a contradiction.

To prove 2 implies 1, we prove the contrapositive. If is not connected, then there are two vertices so that there is no walk from to .

Suppose that , and pick . Any walk from to starts in and ends in , and so at some point there must be an edge from a vertex in to a vertex in , but there are no such edges

Types of Walks

Many questions in graph theory ask whether or not a walk of a certain type exists on a graph: we introduce some notation that will be needed for these questions.

We say a walk is closed if it starts and ends on the same vertex; i.e., . The length of a walk is , the number of edges in it. The distance between two vertices and is the length of the shortest walk from to , if one exists, and if one does not exist.

Walks, trails and paths

  • If the edges of the walk are all distinct, we call it a trail
  • If the vertices of the walk are all distinct (except possibly ), we call the walk a path. The exception is to allow for the possibility of closed paths.

Lemma

Let . The following are equivalent:

  1. There is a walk from to .
  2. There is a trail from to
  3. There is a path from to .

Proof

Obviously, 3 implies 2 which implies 1, as any path is a trail, and any trail is a walk.

That 1 implies 3 is intuitively obvious: if you repeat a vertex, then you’ve visited someplace twice, and weren’t taking the shortest route. Let’s make this argument mathematically precise.

Suppose we have a walk that is not a path. Then, we must repeat some vertex, say , with . Then we can cut out all the vertices and edges between and to obtain a new walk

.

Since , the new walk is strictly shorter than our original walk. Since the length of a walk is finite, if we iterate this process the result must eventually terminate. That means all our vertices are distinct, and hence is a path.