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.

The field of graph theory arguably began with the following question.

The Bridges of Konigsberg

the city of Konigsberg (now Kaliningrad) was built on both sides of a river, and contained two large islands. The 4 sectors of the city were connected by seven bridges, as follows (picture from Wikipedia):

Konigsberg in Euler's time

A group of friends enjoyed strolling through the city, and created a game: could they take a walk in the city, crossing every bridge exactly once, and return to where they started from? Eventually, Euler proved that such a walk is not possible, and in doing so founded graph theory.

Eulerian Cycles

Before presenting Euler’s proof, let us formulate the question precisely in terms of graph theory, which will also generalize the problem.

We can produce a graph , which we will callt he Kingsberg graph, that represents the city of Konigsberg as follows. There will be four vertices, representing the four land-masses are vertices. Every bridge will be represented by an edge.

Then, the question reduces to finding a closed walk in the graph that will uses every edge exactly once. In particular, this walk will not use any edge more than once and hence will be a trail (though it may repeat vertices).

Definition: Eulerian cycle

Let be any graph. An Eulerian cycle or Eulerian tour is a walk in that visits every edge exactly once.

The citizens Konigsberg were asking whether an Eulerian cycle existed in . Euler did more: he gave simple criterion to tell whether or not any connected graph has an Eulerian tour. We will now state and prove his result.

Theorem

A connected graph (without loops) has an Eulerian cycle if and only if every vertex of has even degree.

Proof

First, we show this condition is necessary. Let be a connected graph, and suppose that it has an Eulerian cycle . Let be any vertex in ; we must show that has even degree. We will do this by pairing up the edges incident to .

Since is a closed walked, we may assume that it does not start at . Then consider the first time that the walk visits – it will enter by some edge , and leave by some other edge . We pair these two edges up.

The walk may visit multiple times; each time it does, it must enter from one edge, and leave from another edge. Each time the walk visits , we will pair up the edge the walk entered with the edge left by. Since by supposition the walk uses every edge of exactly once, we see that every edge incident to will be paired up with exactly one other edge in this way, and hence must have even degree.

We now show that this condition is sufficient. That is, we suppose that every vertex of has even degree; we must show that has an Eulerian cycle. We will proceed by induction on the number of edges of .

Any connected graph with 0 edges consists of just a vertex, and hence trivially has an Eulerian cycle.

Now, for the inductive step, we suppose that has edges, and further suppose that we know Euler’s theorem is true for all graphs with less than edges – that is, suppose that every connected graph with less than edges, all of whose vertices have even degree has an Eulerian walk.

We first claim that has some closed trail. Start at any vertex . Since is connected, has at least one edge so we start our trail with . Since every vertex has an even degree, there must be another edge out of , say leading to .

We continue building a trail in by randomly selecting an unused edge of at our current vertex. Since every vertex has even degree, and whenever our trail visits a vertex we use up edges two at a time (coming and going), we see that whenever we arrive at a vertex , there must be another edge leaving it to continue our trail – unless perhaps we hit our starting vertex , where we have only used one edge up. Thus, if we randomly start building a trail we must eventually return to our starting vertex and obtain a closed trail.

Now, given our graph , we know it has some closed trail . If uses every edge of , we are done. If not, we consider the new graph obtained by deleting every edge of (but not the vertices). Note that every vertex of has even degree. Second, may not be connected, but each connected component of has fewer edges that and hence has an Eulerian tour by supposition. Together, and the visit every edge of exactly once. We can stitch them together into one closed path as follows – each shares at least one vertex with . We trace the path , but the first time we visit vertex we insert the path before continuing along .

Hamiltonian Cycles

Definition

A graph is Hamilton if there exists a closed walk that visits every vertex exactly once.

Although the definition of a Hamiltonian graph is extremely similar to an Eulerian graph, it is much harder to determine whether a graph is Hamiltonian or not: doing so is an NP-complete problem.

Examples

Proposition

The Petersen graph is not Hamiltonian.

Proof

Suppose the Petersen graph was Hamiltonian, and let denote the Hamiltonian cycle, as we have drawn below:

The Petersen graph has 15 edges, and the Hamiltonian cycle uses 10 of them, so there must be 5 edges left in the Petersen graph that are not in the Hamiltonian cycle. The proof works by considering the possibilities for these 5 extra edges.

Let us consider the extra edge incident to ; the others are equivalent. Since the Petersen graph has no loops or multiple edges, this edge cannot go from to itself, or to or .

Since the Petersen graph has no triangles or 4 cycles, this edge cannot “skip” 1 or 2 vertices in the Hamiltonian cycle. More specifically, we cannot we cannot have an edge from to or , as these make triangles, as in the dashed edges below:

And we cannot have edges to or to , as these make 4 cycles:

Thus, the only possibility for these edges is that they “skip” 4 or 5 vertices (skipping more than 5 vertices is the same as skipping less vertices in the other direction). So for instance, can only be connected to or with its extra edge.

We now claim that at least one of these extra edges must “skip” 4 vertices. If not, then every extra edge would skip 5 vertices. Since each vertex has degree 3, there must be one extra edge through each of these vertices, connecting to the opposite vertex. But this configuration has many four cycles – for instance, . Since the Petersen graph does not have any 4 cycles, we see this cannot occur:

Relabeling our edges if necesary, we can make the extra edge that skips the 4 cycle be the edge . Now, consider the extra edge at . This cannot skip 5, because that would make it adjacent to , which already has its extra edge. Thus, it must skip 4, and be adjacent to either or . But since each of these are adjacent to , it would create a 4-cycle: either , or .

We have drawn the edge from to in solid red; any of the dashed edges from create a configuration not found in the Petersen graph:

Partial results on Hamiltonian graphs

Although there is no complete characterisation of Hamiltonian graphs, there are several nice sufficient conditions for a graph to be Hamiltonian;

Ore’s Theorem

Let be a simple graph with vertices such that for any two nonadjacent vertices and , we have . Then is Hamiltonian.

Proof

We will give a proof by contradiction. First, suppose that were a counterexample. Adding edges to preserves the condition on the degrees, and so we may continually add edges to until adding any more would create a Hamiltonian cycle. We will thus assume that is a counterexample with the maximal set of edges.

The benefit of this is that such a must have a non-closed path that visits every vertex exactly once. To see this, add one more edge to – the resulting graph then has a Hamiltonian cycle, which must pass through , deleting give the desired path.

Let be the path visiting every vertex of . We will complete the proof by showing there exists an so that is adjacent to and is adjacent to . This completes the proof because is a Hamiltonian path. We illustrate this below, with and :

The existence of such an follows from the pigeon hole principle. Since and are not adjacent by supposition, the sum of their degrees is at least . Two edges incident to them are accounted for , and , so there must be at least other edges incident to or . Since is simple, any such edge out of has possibilities: . Similarly, there are possibilities for an edge adjacent to . We pair these edges up into the possibilities we want, creating bins. Since there are edges we need to distribute among these bins, one of the bins must contain at least two, which is exactly what we needed to show.