LibreCanon › Math
AI Canon. Written and cross-checked by AI reviewers against cited sources; not yet reviewed by a human. Errors are possible. What this means

Graph Theory: Networks, Paths and Coloring

What this article is about

A graph, in graph theory, is a collection of dots for objects and lines for the links between them. The objects can be anything from bus stops to computers to relatives; the graph’s job is to show how the whole network is put together [1, p. 1238]. This article follows OpenStax Contemporary Mathematics, chapter 12 [1]: the parts of a graph, the degree of a vertex, coloring, routes that use every edge once (Euler) or visit every vertex once (Hamilton), the traveling salesperson problem, and trees.

1. Vertices, edges and degree

The dots are called vertices, and a line between two of them is an edge [1, p. 1238]. An edge from a vertex back to that same vertex is a loop. A simple graph is free of loops and never links one pair of vertices with two or more edges; a multigraph is allowed both [1, p. 1238]. The drawing of the edges is irrelevant; all that counts is which vertices each one links [1, p. 1239].

A vertex’s degree counts the edges meeting it [1, p. 1241]. Each new edge adds two to the total of all degrees, because every edge ends at two places, each of which counts once toward a vertex’s degree. Hence the degrees of any graph add up to double its number of edges, a result the book calls the Sum of Degrees Theorem [1, p. 1251].

2. Coloring

To color a graph is to give every vertex a color in such a way that vertices joined by an edge always get different ones; the least number of colors that works is the chromatic number [1, p. 1293]. The book applies this to scheduling. Let each vertex be an event, and draw an edge between two events whenever someone wants to go to both; each color is then a time slot, and the chromatic number is the smallest number of slots that avoids every clash [1, pp. 1292–1293].

No formula gives the chromatic number, and for big graphs a computer is usually needed [1, p. 1293], but a few facts help [1, p. 1294]:

  • a complete graph joins every vertex to all the others, so each needs a color of its own and the chromatic number equals the number of vertices;
  • if some part of a graph is itself complete, a clique, the whole graph needs at least as many colors as its biggest clique has vertices;
  • any planar graph, which can be drawn flat without crossing edges, needs no more than four colors.

The last fact is the four-color theorem. It started as a question about maps: do four colors always suffice to color a map so that regions with a common border differ in color [1, p. 1298]? According to the book, Francis Guthrie saw in the 1800s that a map of the counties of Britain seemed to need only four, and the question went by way of his brother Frederick to August De Morgan, who could not answer it. In 1976 two University of Illinois mathematicians, Kenneth Appel and Wolfgang Haken, settled it by combining graph theory with calculations done by computer; according to the book, it was “the first time in history that a mathematical theorem was proven using a computer” [1, p. 1300].

3. Euler circuits and trails

A walk that never reuses an edge is a trail [1, p. 1326]; a trail that finishes at its starting vertex is a circuit [1, pp. 1292, 1312]. An Euler circuit uses each edge of the graph once, no more and no less, and comes back to where it began [1, p. 1313]; an Euler trail also uses each edge once but may finish somewhere else [1, p. 1326].

The idea comes from Königsberg (now Kaliningrad, Russia), whose waterways were crossed by seven bridges in the 1700s. Was there a walk over every bridge, each crossed only once, ending back at the start? According to the book, Leonhard Euler answered this in 1735 with a multigraph: one vertex per land mass, one edge per bridge [1, p. 1312].

Euler showed that no Euler circuit can pass through a vertex of odd degree. The book makes the case for degree 3: wherever the walk begins, once the third edge at that vertex has been used, the only way to leave it or come back is to reuse one of the three, and the argument works for every odd degree [1, p. 1313]. According to the book, he also proved the converse, giving the Euler circuit theorem: for connected graphs, Euler circuits exist if and only if each of the graph’s vertices has even degree [1, p. 1313]. Not every degree in the Königsberg graph is even, so the walk is impossible [1, p. 1313].

The same reasoning gives the Euler trail theorem. An Euler trail starts and finishes at different vertices; it leaves the first without coming back and arrives at the last without leaving, so exactly those two have odd degree and the rest have even degree [1, p. 1327]. If three or more vertices have odd degree, no Euler trail exists [1, p. 1328].

4. Hamilton cycles

A Hamilton cycle passes through each vertex of a graph once and returns to its start, never using an edge twice [1, pp. 1340–1341]. This idea, too, grew out of puzzles. According to the book, scholars in India and in the Islamic world were already asking in the 800s whether a knight could land on every square of a chessboard, and in 1857 William Rowan Hamilton made a puzzle that asks for a path along a dodecahedron’s edges through each corner once [1, p. 1340].

“The number of distinct Hamilton cycles in a complete graph with n vertices is (n − 1)!” [1, p. 1346]: the book fixes one starting vertex and lists the cycles from there, so what is counted are the orderings of the remaining n − 1 vertices [1, p. 1345]. This counts every cycle twice, once per direction; a cycle and its reverse share their edges and so their total weight [1, pp. 1345, 1347].

5. The traveling salesperson problem

A weighted graph carries a number on each edge, for example a time, a distance or a cost [1, p. 1346]. The traveling salesperson problem looks, within a complete weighted graph, for the Hamilton cycle with the smallest total weight: the cheapest tour of all the locations that ends at home [1, p. 1364]. The book gives two approaches [1, pp. 1364–1374]:

  • the brute force method writes out all the Hamilton cycles, totals each one’s weight and keeps the smallest. Its answer is always the best, but it “can take a very long time to implement” [1, p. 1367], because n vertices in a complete graph give (n − 1)! distinct cycles to check [1, pp. 1346, 1370–1371];
  • the nearest neighbor method is greedy: it moves at every step to the nearest or cheapest unvisited vertex. A greedy algorithm “can be completed in a relatively short time” [1, p. 1367], and it finds “a Hamilton cycle of relatively low weight”: it “usually doesn’t give the best solution, but it usually gives a solution that is ‘good enough’” [1, p. 1371]. Starting from a different vertex can change its result [1, p. 1379].

6. Trees

A tree is a connected graph containing no cycle [1, p. 1380]. Every tree has exactly one edge fewer than it has vertices, and conversely a connected graph with that count is a tree [1, p. 1384].

Inside a connected graph, a spanning tree is any tree that reaches all of the graph’s vertices [1, p. 1386]. One graph may have a great many spanning trees [1, pp. 1386, 1388]. If the edges carry weights, say what it costs to cable two devices together in a computer network, the spanning tree with the lowest total is the minimum spanning tree [1, p. 1391]. The book builds it with Kruskal’s algorithm: take a lightest edge; go on taking the lightest of the remaining edges, whether or not it touches those already taken, but skip any edge that would close a cycle; stop once the chosen edges form a spanning tree [1, pp. 1391–1392].

Not covered here

Sources

[1]OpenStax, Contemporary Mathematics, chapter 12 “Graph Theory”: §12.1 “Graph Basics” (pp. 1238–1241), §12.2 “Graph Structures” (p. 1251), §12.4 “Navigating Graphs” (pp. 1292–1300), §12.5 “Euler Circuits” (pp. 1312–1313), §12.6 “Euler Trails” (pp. 1326–1328), §12.7 “Hamilton Cycles” (pp. 1340–1347), §12.9 “Traveling Salesperson Problem” (pp. 1364–1379) and §12.10 “Trees” (pp. 1380–1392). View at source ↗

Works cited