Login
📚 Contemporary Mathematics
Chapters ▾
⇩ Download ▾

12.4 Navigating Graphs

People walking through a maze of hedges.
Figure 12.68 Visitors navigate a garden maze.Visitors navigate a garden maze. (credit: “Longleat Maze” by Niki Odolphie/Wikimedia, CC BY 2.0)

Learning Objectives

After completing this section, you should be able to:

  1. Describe and identify walks, trails, paths, and circuits.
  2. Solve application problems using walks, trails, paths, and circuits.
  3. Identify the chromatic number of a graph.
  4. Describe the Four-Color Problem.
  5. Solve applications using graph colorings.

Now that we know the basic parts of graphs and we can distinguish one graph from another, it is time to really put our graphs to work for us. Many applications of graph theory involve navigating through a graph very much like you would navigate through a maze. Imagine that you are at the entrance to a maze. Your goal is to get from one point to another as efficiently as possible. Maybe there are treasures hidden along the way that make straying from the shortest path worthwhile, or maybe you just need to get to the end fast. Either way, you definitely want to avoid any wrong turns that would cause unnecessary backtracking. Luckily, graph theory is here to help!

Walks

Suppose Figure 12.69 is a maze you want to solve. You want to get from the start to the end.

A maze with its start and end labeled.
Figure 12.69 Your Maze

You can approach this task any way you want. The only rule is that you can’t climb over the wall. To put this in the context of graph theory, let’s imagine that at every intersection and every turn, there is a vertex. The edges that join the vertices must stay within the walls. The graph within the maze would look like Figure 12.70.

A maze with its start and end labeled. Vertices are marked at each corner of the maze. A path connects all the vertices of the maze.
Figure 12.70 The Graph in Your Maze

One approach to solving a maze is to just start walking. It is not the most efficient approach. You might cross through the same intersection twice. You might backtrack a bit. It’s okay. We are just out for a walk. It might look something like the black sequence of vertices and edges in Figure 12.71.

A maze with its start and end labeled. Vertices are marked at each corner of the maze. A path connects all the vertices of the maze. The path from start to end is highlighted.
Figure 12.71 The Walk Through the Graph in Your Maze

This type of sequence of adjacent vertices and edges is actually called a walk (or directed walk) in graph theory too!

A walk can be identified by naming the sequence of its vertices (or by naming the sequence of its edges if those are labeled). Let’s take the graph out of the context of the maze and give each vertex a name and each edge of the walk a direction as in Figure 12.72.

A graph with 19 vertices and 19 edges. The vertices are a, l, e, h, m, p, r, q, s, o, n, i, j, k, g, c, d, f, and b. The edges connect l a, a b, b f, e f, e h, h m, r s, p q, c d c j, g k, i j, j k, i n, n o, o q, and k s. The following path is highlighted p, q, o, n, i, j, k, s, and r. p is labeled start and q is labeled end. The edges from j to c and c to d are connected via double-headed arrows.
Figure 12.72 The Graph without Your Maze

The name of this walk from p to r is pqonijcdcjksr. When a particular edge on our graph was traveled in both directions, it had arrows in both directions and the letters of vertices that were visited more than once had to be repeated in the name of the walk.

Two graphs are labeled graph X and graph Y. Graph X has six vertices: a, b, c, d, e, and f. The vertices a, b, and e are connected by three edges and it resembles a triangle. The vertices, c, d, and f are connected by three edges and it resembles a triangle. These two triangles overlap and the point where they overlap has no vertex. The edges from b to d and d to f are highlighted. Graph Y is the same as that of graph X. The point where they overlap has a vertex, g.
Figure 12.73 A Walk or Not a Walk?

The highlighted edges Graph Y in Figure 12.73 represent a walk between f and b. The highlighted edges in Graph X do not represent a walk between f and b, because there is a turn at a point that is not a vertex. This is like climbing over a wall when you are walking through a maze. Another way of saying this is that bdf is not a walk, because there is no edge between b and d.

Paths and Trails

A walk is the most basic way of navigating a graph because it has no restrictions except staying on the graph. When there are restrictions on which vertices or edges we can visit, we will call the walk by a different name. For example, if we want to find a walk that avoids travelling the same edge twice, we will say we want to find a trail (or directed trail). If we want to find a walk that avoids visiting the same vertex twice, we will say, we want to find a path (or directed path).

Walks, trails, and paths are all related.

  1. All paths are trails, but trails that visit the same vertex twice are not paths.
  2. All trails are walks, but walks in which an edge is visited twice would not be trails.

We can visualize the relationship as in Figure 12.78.

Three concentric ovals represent paths, trails, and walks. The first (inner) oval labeled paths reads, no repeated edges or vertices. The second oval labeled trails reads, no repeated edges. The third oval is labeled walks.
Figure 12.78 Walks, Trails, and Paths

Let’s practice identifying walks, trails, and paths using the graphs in Figure 12.79.

Two graphs are labeled graph A and graph K. Graph A has five vertices: b, c, d, e, and f. The edges connect b c, c f, b d, b e, d e, and e f. Graph K has five vertices: m, n, o, p, and q. The edges connect m n, n o, n q, q o, o p, n p, and m p.
Figure 12.79 Graphs A and K

Circuits

In many applications of graph theory, such as creating efficient delivery routes, beginning and ending at the same location is a requirement. When a walk, path, or trail end at the same location or vertex they began, we call it closed. Otherwise, we call it open (does not begin and end at the same location or vertex). Some examples of closed walks, closed trails, and closed paths are given in in the following table.

Table 12.4
DESCRIPTIONEXAMPLECHARACTERISTICS
A closed walk is a walk that begins and ends at the same vertex. dfbcfdAlternating sequence of vertices and edges Begins and ends at the same vertex
A closed trail is a trail that begins and ends at the same vertex. It is commonly called a circuit. dfbcfedNo repeated edges Begins and ends at the same vertex
A closed path is a path that begins and ends at the same vertex. It is also referred to as a directed cycle because it travels through a cyclic subgraph. dfbcdNo repeated edges or vertices Begins and ends at the same vertex

Since walks, trails, and paths are all related, closed walks, circuits, and directed cycles are related too.

  1. All circuits are closed walks, but closed walks that visit the same edge twice are not circuits.
  2. All directed cycles are circuits, but circuits in which a vertex is visited twice are not directed cycles.

We can visualize the relationship as in Figure 12.84.

Three concentric ovals represent directed cycles, circuits, and closed walks. The first (inner) oval labeled directed cycles (closed paths) reads, no repeated edges or vertices. The second oval labeled circuits (closed talks) reads, no repeated edges. The third oval is labeled closed walks.
Figure 12.84 Closed Walks, Circuits, and Directed Cycles

The same circuit can be named using any of its vertices as a starting point. For example, the circuit dfbcd can also be referred to in the following ways.

abcda is the same as

{ bcdabcdabcdabcd

Let’s practice working with closed walks, circuits (closed trails), and directed cycles (closed paths). In the graph in Figure 12.85, the vertices are major central and south Florida airports. The edges are direct flights between them.

A graph represents the direct flights between Central and South Florida airports. The graph has six vertices: T P A, M C O, P B I, F L L, M I A, and E Y W. Edges from T P A lead to E Y W, M I A, F L L, and P B I. Edges from M C O lead to E Y W, M I A, and F L L. An edge from E Y W leads to F L L.
Figure 12.85 Major Central and South Florida Airports

Graph Colorings

In this section so far, we have looked at how to navigate graphs by proceeding from one vertex to another in a sequence that does not skip any vertices, but in some applications we may want to skip vertices. Remember the camp Olympics at Camp Woebegone in Comparing Graphs? You were planning a camp Olympics with four events. The campers signed up for the events. You drew a graph to help you visualize which events have campers in common. The vertices of Graph E in Figure 12.87 represent the events and adjacent vertices indicate that there are campers who are participating in both.

A graph with four vertices: a, b, c, and d. The edges connect a b, b d, d c, and c a.
Figure 12.87 Graphs of Camp Olympics

In this case, we do NOT want events represented by two adjacent vertices to occur in the same timeslot, because that would prevent the campers who wanted to participate in both from doing so. We can use the graph in Figure 12.87 to count the timeslots we need so there are no conflicts. Let’s assign each timeslot a different color. We could categorize events that happen at 1 pm as Red; 2 pm, Purple; 3 pm, Blue; and 4 pm, Green. Then assign different colors to any pair of adjacent vertices to ensure that the events they represent do not end up in the same timeslot. Figure 12.88 shows several of the ways to do this while obeying the rule that no pair of adjacent vertices can be the same color.

Three graphs are labeled graph 1, graph 2, and graph 3. Graph 1 has four vertices: a, b, c, and d in blue, green, purple, and red, respectively. Graph 2 has four vertices: a, b, c, and d in blue, purple, purple, and red, respectively. Graph 3 has four vertices: a, b, c, and d in red, purple, purple, and red, respectively. In each graph, the edges connect a b, b d, d c, and c a.
Figure 12.88 Graph Colorings

In Figure 12.88, the graphs with vertices colored so that no adjacent vertices are the same color are called graph colorings. Notice that Graph 3 has the fewest colors, which means it shows us how to have the fewest number of timeslots. The events marked in red, a and d, can be held at the same time because they are not adjacent and do not have conflicts. Also, the events marked in purple, b and c, can be held at the same time. We would not need green or blue timeslots at all!

A graph that uses n colors is called an n-coloring. The smallest number of colors needed to color a particular graph is called its chromatic number.

Graph colorings can be used in many applications like the scheduling scenario at camp Woebegone. Let's look at how they work in more detail. Figure 12.89 shows two different colorings of a particular graph. Coloring A is called a four-coloring, because it uses four colors, red (R), green (G), blue (B), and purple (P). Coloring B is called a three-coloring because it uses three. The colors allow us to visually subdivide the graphs into groups. The only rule is that adjacent vertices are different colors so that they are in different groups.

Two graphs are labeled coloring A and coloring B In the first graph, nine vertices are present. The vertices are arranged in 3 rows and 3 columns. Row 1: B, G, and R. Row 2: G, R, and P. Row 3: P, B, and G. The outer vertices are connected to form a square. A vertical line and a horizontal line at the center connect G R, R B, G R, and R P. Diagonal lines connect B R, R G, G B, and G P. In the second graph, nine vertices are present. The vertices are arranged in 3 rows and 3 columns. Row 1: B, G, and R. Row 2: G, R, and B. Row 3: R, B, and G. The outer vertices are connected to form a square. A vertical line and a horizontal line at the center connect G R, R B, G R, and R B. Diagonal lines connect B R, R G, G B, and G B.
Figure 12.89 Two Colorings of the Same Graph

It turns out that a three-coloring is the best we can do with the graph in Figure 12.89. No matter how many different patterns you try with only two colors, you will never find one in which the adjacent vertices are always different colors. In other words, the graph has a chromatic number of three. For large graphs, computer assistance is usually required to find the chromatic numbers. There is no formula for finding the chromatic number of a graph, but there are some facts that are helpful in Table 12.5.

Table 12.5
FactExample
Recall that planar graphs are untangled; that is, they can be drawn on a flat surface so that no two edges are crossing. If a graph is planar, it can be colored with four colors or possibly fewer.
Each vertex in a complete graph is adjacent to every other vertex forcing us to color them all different colors.The chromatic number of a complete graph is the same as the number of vertices.
If a graph has a clique, a complete subgraph, then each vertex in the clique must have a different color and the vertices outside the clique may or may not have even more colors. The chromatic number of a graph is at least the number of vertices in its biggest clique.

Creating Colorings to Solve Problems

Let’s see how these facts can help us color the graph in Figure 12.90.

  • Since the graph is planar, the chromatic number is no more than four.
  • The graph is not complete, but it has complete subgraphs of three vertices. In other words, it has triangles like the one shown with blue vertices in Figure 12.90. This means that the chromatic number is at least three.
A graph has nine vertices arranged in 3 rows and 3 columns. The outer vertices are connected to form a square. A vertical line and a horizontal line at the center connect the vertices along the lines. Diagonal lines from top-left to bottom-right connect the vertices along the lines. The vertices at the top-left, left-center, and center are highlighted in grey.
Figure 12.90 A Graph with Triangles

We know we can color this graph in three or four colors. It is usually best to start by coloring the vertex of highest degree as shown in Figure 12.91. In this case, we used red (R). The color is not important.

Two graphs are labeled degrees of vertices and degree 6 vertex colored first. In the first graph, nine vertices are present. The vertices are arranged in 3 rows and 3 columns. Row 1: 3, 4, and 2. Row 2: 4, 6, and 4. Row 3: 2, 4, and 3. In the second graph, nine vertices are present. The vertices are arranged in 3 rows and 3 columns. Row 1: 3, 4, and 2. Row 3: 4, R, and 4. Row 3: 2, 4, and 3. In each graph, the outer vertices are connected to form a square. A vertical line and a horizontal line at the center connect the vertices along the lines. Diagonal lines from top-left to bottom-right connect the vertices along the lines. An arrow from the first graph points to the second graph.
Figure 12.91 Color Highest Degree Vertex First

We want to color as many of the vertices the same color as possible; so, we look at all the vertices that are not adjacent to the red vertex and begin to color them, red starting with the one among them of highest degree. Since the only vertices that are not adjacent are both degree 2, choose either one and color it red as shown in Figure 12.92.

Two graphs. In the first graph, nine vertices are present. The vertices are arranged in 3 rows and 3 columns. Row 1: 3, 4, and 2. Row 3: 4, R, and 4. Row 3: 2, 4, and 3. 2 in the top-right and bottom-left vertices are outlined. In the second graph, nine vertices are present. The vertices are arranged in 3 rows and 3 columns. Row 1: 3, 4, and R. Row 2: 4, R, and 4. Row 3: 2, 4, and 3. In each graph, the outer vertices are connected to form a square. A vertical line and a horizontal line at the center connect the vertices along the lines. Diagonal lines from top-left to bottom-right connect the vertices along the lines. An arrow from the first graph points to the second graph.
Figure 12.92 Color More Red from Highest to Lowest Degree

Now, there is only one vertex left that is not adjacent to a red; so, color it red. Of the remaining vertices, the highest degree is four; so, color one of the vertices of degree four in a different color. These two steps are shown in Figure 12.93.

Two graphs. In the first graph, nine vertices are present. The vertices are arranged in 3 rows and 3 columns. Row 1: 3, 4, and R. Row 3: 4, R, and 4. Row 3: R, 4, and 3. In the second graph, nine vertices are present. The vertices are arranged in 3 rows and 3 columns. Row 1: 3, B, and R. Row 2: 4, R, and 4. Row 3: R, 4, and 3. In each graph, the outer vertices are connected to form a square. A vertical line and a horizontal line at the center connect the vertices along the lines. Diagonal lines from top-left to bottom-right connect the vertices along the lines. An arrow from the first graph points to the second graph.
Figure 12.93 Complete the Reds and Start Another Color

Repeat the same procedure. There are three remaining vertices that are not adjacent to a blue. Color as many blue as possible, with priority going to vertices of higher degree as shown in Figure 12.94.

Three graphs. In the first graph, nine vertices are present. The vertices are arranged in 3 rows and 3 columns. Row 1: 3, B, and R. Row 3: 4, R, and 4. Row 3: R, 4, and 3. 4 in the left-center and bottom-center vertices are outlined. 3 in the bottom-right vertex is outlined. In the second graph, nine vertices are present. The vertices are arranged in 3 rows and 3 columns. Row 1: 3, B, and R. Row 2: B, R, and 4. Row 3: R, 4, and 3. 3 in the bottom-right vertex is outlined. In the third graph, nine vertices are present. The vertices are arranged in 3 rows and 3 columns. Row 1: 3, B, and R. Row 2: B, R, and 4. Row 3: R, 4, and B. In each graph, the outer vertices are connected to form a square. A vertical line and a horizontal line at the center connect the vertices along the lines. Diagonal lines from top-left to bottom-right connect the vertices along the lines. An arrow from the first graph points to the second graph. An arrow from the second graph points to the third graph.
Figure 12.94 Repeat Procedure for Color Blue

All the remaining vertices are adjacent to blue. So, it is time to repeat the procedure with another color as shown in Figure 12.95.

Three graphs. In the first graph, nine vertices are present. The vertices are arranged in 3 rows and 3 columns. Row 1: 3, B, and R. Row 3: B, R, and P. Row 3: R, 4, and B. 3 in the top-left vertex is outlined. 4 in the bottom-center is outlined. In the second graph, nine vertices are present. The vertices are arranged in 3 rows and 3 columns. Row 1: 3, B, and R. Row 2: B, R, and P. Row 3: R, P, and B. 3 in the top-left vertex is outlined. In the third graph, nine vertices are present. The vertices are arranged in 3 rows and 3 columns. Row 1: P, B, and R. Row 2: B, R, and P. Row 3: R, P, and B. In each graph, the outer vertices are connected to form a square. A vertical line and a horizontal line at the center connect the vertices along the lines. Diagonal lines from top-left to bottom-right connect the vertices along the lines. An arrow from the first graph points to the second graph. An arrow from the second graph points to the third graph.
Figure 12.95 Repeat Procedure for Color Purple

All the vertices are now colored with a three-coloring so we know the chromatic number is at most three, but we knew the chromatic number was at least three because the graph has a triangle. So, we are now certain it is exactly three.

Suppose the vertices of the graph in Figure 12.96 represented the nine events in the Camp Woebegone Olympics, and edges join any events that have campers in common, but nonadjacent vertices do not.

A graph has nine vertices. The vertices are arranged in 3 rows and 3 columns. Row 1: P, B, and R. Row 2: B, R, and P. Row 3: R, P, and B. In each graph, the outer vertices are connected to form a square. A vertical line and a horizontal line at the center connect the vertices along the lines. Diagonal lines from top-left to bottom-right connect the vertices along the lines.
Figure 12.96 Coloring for Nine Event Camp Woebegone Olympics

Any vertices of the same color are nonadjacent; so, they have no conflicts. Since this graph is a three-coloring, all nine events could be scheduled in just three timeslots!

The Four Color Problem

Two figures. The first figure shows a rectangle divided into several small blocks. The second figure is the same as that of the first figure with the addition that the blocks are shaded in 4 different colors.
Figure 12.98 Using only four colors, no two adjacent regions have the same color.

The idea of coloring graphs to solve problems was inspired by one of the most famous problems in mathematics, the “four color problem.” The idea was that, no matter how complicated a map might be, only four colors were needed to color the map so that no two regions that shared a boundary would be the same color. For many years, everyone suspected this to be true, because no one could create a map that needed more than four colors, but they couldn’t prove it was true in general. Finally, graphs were used to solve the problem!

We saw how maps can be represented as graphs in Graph Basics. Figure 12.99 from Example 4 in Section 12.1 shows a map of the midwestern region of the United States.

A partial map of the USA with midwestern states. The Midwestern states are North Dakota, South Dakota, Nebraska, Kansas, Minnesota, Iowa, Missouri, Wisconsin, Illinois, Indiana, Michigan, and Ohio.
Figure 12.99 Map of Midwestern States

Figure 12.100 shows how this map can be associated with a graph in which each vertex represents a state and each edge indicates the states that share a common boundary. Figure 12.101 shows the final graph.

A partial map of the USA with midwestern states. The Midwestern states are North Dakota (N D), South Dakota (S D), Nebraska (N E), Kansas (K S), Minnesota (M N), Iowa (I A), Missouri (M O), Wisconsin (W I), Illinois (I L), Indiana (I N), Michigan (M I), and Ohio (O H). Edges from N D connect with S D and M N. Edges from S D connect with N E, I A, and M N. Edges from M N connect with I A and W I. Edges from N E connect with K S, M O, and I A. Edges from I A connect with M O and I L. Edges from W I connect with I A and I L. An edge from K S connects with M O. An edge from M O connects with I L. An edge from I L connects with I N. Edges from I N connect with M I and O H. An edge from M I connects with O H.
Figure 12.100 Edge Assigned to Each Pair of Midwestern States with Common Border
A graph represents common boundaries between midwestern states. The vertices are North Dakota (N D), South Dakota (S D), Nebraska (N E), Kansas (K S), Minnesota (M N), Iowa (I A), Missouri (M O), Wisconsin (W I), Illinois (I L), Indiana (I N), Michigan (M I), and Ohio (O H). Edges from M N connect with I A and W I. Edges from N E connect with K S, M O, and I A. Edges from I A connect with M O and I L. Edges from W I connect with I A and I L. An edge from K S connects with M O. An edge from M O connects with I L. An edge from I L connects with I N. Edges from I N connect with M I and O H. An edge from M I connects with O H.
Figure 12.101 Final Graph Representing Common Boundaries between Midwestern States

Notice that the graph representing the common boundaries between midwestern states is planar, meaning that it can be drawn on a flat surface without edges crossing. As we have seen, any planar graph has a chromatic number of four or less. This very well-known fact is called the Four-Color Theorem, or Four-Color Map Theorem.

Key Terms

  • walk (directed walk)
  • trail (directed trail)
  • path (directed path)
  • closed
  • open
  • closed walk
  • circuit (closed trail)
  • directed cycle (closed path)
  • coloring (graph coloring)
  • n-coloring
  • chromatic number

Key Concepts

  • Walks, trails, and paths are ways to navigate through a graph using a sequence of connected vertices and edges.
  • Closed walks, circuits, and directed cycles are ways to navigate from a vertex on a graph and return to the same vertex.
  • Colorings are a way to organize the vertices of a graph into groups so that no two members of a group are adjacent.
  • Maps can be represented with planar graphs, which can always be colored using four colors or fewer.

Videos

Adapted from Contemporary Mathematics by OpenStax (openstax.org), licensed under CC BY-NC-SA 4.0. Changes were made. License: CC-BY-NC-SA-4.0.