Graph Theory - New Mexico State...

55
Graph Theory Graph Theory 1/55

Transcript of Graph Theory - New Mexico State...

Page 1: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Graph Theory

Graph Theory 1/55

Page 2: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Graph theory was invented by a mathematician named Euler in the18th century. We will see some of the problems which motivated itsstudy. However, it wasn’t studied too systematically until the latterhalf of the 20th century. Computer Science applications have drivenits development, since many CS problems are naturally modeled viagraphs.

The first problem we’ll look at is the historical motivation of thesubject, the Seven Bridges of Konigsburg problem.

Graph Theory 2/55

Page 3: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Leonard Euler

Leonard Euler (pronounced Oiler) was aSwiss mathematician of the 18thcentury. He was extremely prolific, andhis work influenced many areas ofmathematics. He spent most of hiscareer in St. Petersburg and Berlin.Besides graph theory, he contributed tonumber theory, including proving hisgeneralization of Fermat’s little theoremused in RSA encryption.

Graph Theory 3/55

Page 4: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Euler also came up with the formula

eπi + 1 = 0

relating the irrational number π and the imaginary number i .

Graph Theory 4/55

Page 5: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Seven Bridges of Konigsburg

The origin of graph theory was the following problem. In the city ofKonigsburg, Russian occupied territory next to Lithuania, there areseven bridges passing over the river connecting various parts of thecity.

The following picture shows the city and its bridges.

Graph Theory 5/55

Page 6: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Konigsburg

Graph Theory 6/55

Page 7: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Another Picture of the Seven Bridges

Graph Theory 7/55

Page 8: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

The problem, possibly originating from people strolling around thecity, is this: Is it possible to cross each bridge exactly once and endup where you started?

A variation is to ask: Is it possible to cross each bridge exactly once,regardless of where you start and end?

Try to find a way to cross each bridge exactly once. Also try the samething on the second picture below. If you cannot, try to think aboutwhether it is because you aren’t trying hard enough or if it looks to beimpossible.

Graph Theory 8/55

Page 9: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Can you Find a Path to Cross Each Bridge Exactly Once?

A Found a path for both pictures

B Found a path for just the left picture

C Found a path for just the right picture

D Didn’t find a path for either

Graph Theory 9/55

Page 10: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Answer

If you didn’t find a path for the picture on the left, don’t feel bad.We’ll see that it is impossible.

For the picture on the right there is a path that crosses each bridgeexactly once. For example, here is a path starting on the north shoreand ending on the east island.

It is not possible to do this while starting and ending on the sameland mass. We’ll explore why.

Graph Theory 10/55

Page 11: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

What is a Graph?

Euler solved this problem by representing the situation as a structurewhich we now call a graph. This use of the term graph is differentthan that occurring in algebra.

We will illustrate how Euler used graph theory to solve the 7 bridgesproblem. We will also address other problems which can be solved bythe use of graph theory.

A graph consists of a bunch of points, usually called vertices. Some ofthe vertices are connected to each other. When a vertex is connectedto another, that connection is called an edge. We can draw edges asstraight line segments or curves.

Here are some examples of graphs.

Graph Theory 11/55

Page 12: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Graph Theory 12/55

Page 13: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

The first two graphs look different, but they represent the sameinformation. Both have the top three vertices connected to each of thethree bottom vertices. That the edges in the left figure sometimes aredrawn with straight lines and sometimes with curves does not matter. Nordoes it matter where the vertices are positioned.

Graph Theory 13/55

Page 14: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Euler represented the 7 bridges problem as a graph in the followingway. Each land mass was represented as a vertex. Two vertices areconnected by an edge if the corresponding land masses are connectedby a bridge.

The graph representing the situation is shown on the next slide. Aswe have indicated, the shape of the edges is irrelevant. Only whatmatters are which vertices are connected.

Since there are 4 land masses, there are 4 vertices. The 7 bridgescorrespond to 7 edges.

Graph Theory 14/55

Page 15: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Clicker Question

Does one of these graphs represent thebridge network of Konigsburg?

A The top graph

B The bottom graph

C Neither

D Both

Graph Theory 15/55

Page 16: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Answer

A The top graph represents the seven bridges of Konigsburg.

Graph Theory 16/55

Page 17: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Graph of the 8 Bridges of Who-ville

The other graph represents the eight bridges of WhoVille.

Graph Theory 17/55

Page 18: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Some Graph-Theoretic Concepts

A path on a graph is a journey through various vertices, where youcan go from one to another as long as there is an edge connectingthem. A circuit is a path which returns to the starting point.

This idea comes from the original motivation for graphs. A path inthe 7 bridges graph can be though of as a walk across various bridges.

Graph Theory 18/55

Page 19: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

In honor of Euler’s work, we call a path which crosses each edgeexactly once an Euler path.

If the Euler path starts and ends at the same vertex, then it is calledan Euler circuit.

Besides this problem, a reason for wanting to consider such paths isto minimize driving. A UPS truck wants to make deliveries asefficiently as possible, so doesn’t want to repeat driving down a streetif it is not necessary.

In terms of graph theory, the 7 bridges problem is then: Is there anEuler circuit (or Euler path) on the graph representing Konigsburg?

Graph Theory 19/55

Page 20: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Clicker Question

Before we see how Euler solved the problem, here are some moreexamples to try.

How many of the following graphs can you trace a path over each ofthese figures without lifting your pencil or retracing any linesegments? Enter how many of these five that you can trace such apath.segments?

Graph Theory 20/55

Page 21: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Answer

The pictures with the green checkmark can be traced as desired, theones with the red x cannot.

The second and fourth can be traced but not starting and ending atthe same point.

Graph Theory 21/55

Page 22: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Clicker Question

Here is another set of graphs. How many can you trace a path overeach of these figures without lifting your pencil or retracing any linesegments? Enter how many of these five that you can trace such apath.

Graph Theory 22/55

Page 23: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Answer

The pictures with the green checkmark can be traced as desired, theones with the red x cannot.

The fourth can be traced but not starting and ending at the samepoint.

Graph Theory 23/55

Page 24: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Euler’s Solution of the 7 Bridges Problem

Euler discovered that, in order to have an Euler circuit, the number ofedges connected to each vertex must be even.

The number of edges connected to a given vertex is called the degreeof the vertex.

He also saw that in order to have an Euler path, every vertex, exceptfor at most two, must have even degree. If two have odd degree,those could only be the start and the end of the path.

Graph Theory 24/55

Page 25: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

The graph to the left has an Euler circuit. The one to the right doesnot, but it does have an Euler path, when one starts at the top leftvertex and finishes at the top right.

Graph Theory 25/55

Page 26: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Roughly, Euler reasoned that if there was an Euler path or circuit,then for any vertex other than the start or finish, each time youreached the vertex, you need two edges, one to get there and one toget away. The number of edges connected to the vertex is then twicethe number of times you cross the vertex, and so is an even number.

Graph Theory 26/55

Page 27: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Since the 7 bridges graph has 3 vertices with an odd number of edgesconnected to them, there is no Euler path or Euler circuit.

Thus, it is impossible to walk across each of the 7 bridges exactlyonce.

Graph Theory 27/55

Page 28: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

For the 8 Bridges of Who-ville, two vertices have an even number ofedges connected to them. The other two, the north land and eastisland, have an odd number. We can then start at the north and endat the east island, or vice-versa, and do an Euler path.

Graph Theory 28/55

Page 29: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

The Four Color Theorem

Graph Theory 29/55

Page 30: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

We are now going to investigate the issue of coloring maps and howmany colors are required. We’ll see that this is a graph theoryproblem.

Recall that a graph is a collection of points, called vertices, and acollection of edges, which are connections between two vertices.Edges can be drawn as straight lines or curves; it doesn’t matter howwe draw them.

The problem of map coloring arose as a topic of mathematicalinterest. It generated a lot of interest and trying to determine thesmallest number of colors any map needs was worked on by manypeople for many years. It turns out to be quite a difficult problem,and had many incorrect solutions before the result was finally provedin 1977 that 4 colors suffice.

Graph Theory 30/55

Page 31: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Coloring Maps and the Four Color Theorem

Map makers draw maps in such a way that when two regions bordereach other, they aren’t given the same color. This makes it easier toread the map.

In 1852, Francis Guthrie, while coloring a map of counties in England,noticed that he could do this with only four colors. He asked hisbrother, a mathematician, if that always happened. This led to thefollowing question.

Can every map be colored, so that bordering regions have differentcolors, with at most four colors?

The result we will discuss is now known as the Four Color Theorem.

Graph Theory 31/55

Page 32: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Several top mathematicians worked on the problem, and there wereseveral incorrect attempts. In 1890, Percey Heawood, while trying tounderstand a purported proof by Kempe, found a flaw in Kempe’sproof, and subsequently proved that all maps can be colored with atmost 5 colors.

To understand the problem better, let’s consider some examples.

First, we can associate a graph to a map in the following way. Thevertices of the graph are the regions. Two regions are connected byan edge if they share a border other than a corner. When two regionsshare a border other than a corner we’ll call them adjacent.

Graph Theory 32/55

Page 33: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

New Mexico is adjacent to Texas, Arizona, Colorado, and Oklahoma,but it is not adjacent to Utah, because they only share a corner.

Graph Theory 33/55

Page 34: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Graph of the 4 corners region

Graph Theory 34/55

Page 35: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

For another example, consider the piece of the U.S. consisting ofCalifornia, Nevada, and Arizona. Then this piece of the map isrepresented by the following graph.

Graph Theory 35/55

Page 36: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Clicker Question

How many colors does this piece of the map need in order to notcolor adjacent states the same color?

Graph Theory 36/55

Page 37: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Answer

We need three colors. If we color California red, then Nevada must beanother color, say blue, since it is adjacent to California. BecauseArizona is adjacent to both California and Nevada, it must be anothercolor, say green. We thus need at least 3 colors.

Graph Theory 37/55

Page 38: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

More generally, if the graph of a map contains a piece as below,where there are 3 vertices and each is connected to the other 2, thenthe map needs at least 3 colors.

Graph Theory 38/55

Page 39: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Clicker Question

What is the fewest number of colors we can color this piece of the U.S.map, with 6 states, and not have two states who share a border coloredwith the same color? Enter the number on your clicker.

Graph Theory 39/55

Page 40: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Answer

We need four colors, as the following graph indicates.

Graph Theory 40/55

Page 41: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

If we start coloring the vertex in the middle and then color by goingaround in a circle, we’ll see that we can’t do this with 3 colors. Thereare five vertices on the outside. By a similar argument, we can seethat if there is an odd number of vertices on the outside, allconnected to a central vertex, we need 4 colors.

Graph Theory 41/55

Page 42: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

If we had an even number of vertices on the outside, we could get bywith 3 colors.

Here are some examples of this situation. With an even number ofoutside vertices, you can alternative between two colors afterchoosing the color for the center vertex.

This doesn’t work with an odd number of vertices.

Graph Theory 42/55

Page 43: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

For another example, consider the following map of Europe.

Graph Theory 43/55

Page 44: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

More specifically, let’s consider the following piece involving Belgium,France, Luxembourg, and Germany.

Graph Theory 44/55

Page 45: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Clicker Question

Here is the graph associated to thispiece of the map. Can you color it withthree colors?

A Yes

B No

Graph Theory 45/55

Page 46: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Answer

No, this piece of the map needs at least four colors. Each vertex isconnected each other, so no two vertices can have the same color.We then need four colors since we have four vertices.

Graph Theory 46/55

Page 47: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

More generally, if the graph representing a map has a piece consistingof 4 vertices, with each vertex connected to each other, then the mapwill require at least 4 colors. The following graph looks different fromthe previous 4 vertex graph, but it has the same information.

Graph Theory 47/55

Page 48: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

We have seen that a 3 vertex graph where each vertex is connected toall others needs 3 colors, and a 4 vertex graph where each vertex isconnected to all others needs 4 colors. Does this pattern hold ingeneral? Here is the 5 vertex version:

Graph Theory 48/55

Page 49: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Clicker Question

What is the fewest colors you need in order to color vertices so thatadjacent vertices are different colors?

Graph Theory 49/55

Page 50: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Answer

The graph needs 5 colors. If we used 4 or fewer colors, since there are5 vertices, then two vertices would have to have the same color. Thisis not possible, since all vertices are connected.

Doesn’t this disprove the Four Color Theorem?

Actually no, since it turns out that this is not the graph of any map.We will say more about this later.

Graph Theory 50/55

Page 51: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

The attempt to solve the map coloring problem has had manyincorrect solutions.

For example, consider the following graph.

Graph Theory 51/55

Page 52: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

This is a map with 10 regions; the “outside” is one of the regions.This coloring makes it appear that we need 5 colors to color it.

Can you recolor it and use fewer colors?

Graph Theory 52/55

Page 53: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

The map can be colored with 4 colors, as the following picture shows.

Graph Theory 53/55

Page 54: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Through a considerable amount of graph theory, the Four ColorTheorem was reduced to a finite, but large number (8900) of specialcases.

Appel and Haken published an article in Scientific American in 1977which showed that the answer to the problem is yes: you can colorany map with at most four colors and not need to color any adjacentregions with the same color.

This was the first widely known mathematical proof which used acomputer to check many cases. At the time this use of machines wasvery controversial, since nobody could check all the details, only thecommands in the program used to do the checking.

Graph Theory 54/55

Page 55: Graph Theory - New Mexico State Universitysierra.nmsu.edu/morandi/oldwebpages/math210Spring2015... · 2015-01-11 · Graph theory was invented by a mathematician named Euler in the

Next Time

Why isn’t the example of the pentagon graph we considered earliernot a counterexample to the Four Color Theorem?

We’ll look at this next time. We’ll also look at how certain shapescalled surfaces can be understood through graph-theoretic ideas.

Graph Theory 55/55