beanz Magazine

Sprouts and Graph Theory

MissMessie on Flickr

How can we apply the Konigsberg Bridge problem to real life and even make a game out of it? With Spouts of course!

In 1735 a famous mathematician by the name of Leonhard Euler solved a problem known as the Konigsberg Bridge problem. The general idea is that the city of Konigsberg has seven bridges connecting four pieces of land that are separated by a forked river passing through. The challenge is to determine whether or not it is possible to reach all four sections of land by passing over each bridge exactly one time.

The situation in Konigsberg looked something like this (bridges outlined in two shades of purple):

However, Euler redrew the problem using dots to represent the land, and edges to represent the bridges.

By abstracting the landscape into these two ideas that are key to the challenge at hand, he was able to prove that the number of bridges must be an even number in order to cross each bridge one time and reach all parts of Konigsberg. Thus, with seven bridges, it is not possible.

When Euler redrew the land and bridges of Konigsgberg, he created what is now known in graph theory as a “graph”. In graph theory, graphs look more like Euler’s graph than like the graphs we see in most math classes. They consist of nodes (dots or vertices) connected by edges (lines or curves) that represent the key parts of a problem.

By simplifying a situation down to nodes and edges, we can solve a range of problems, many of which are particularly valuable in computer science.

Take, for example, social media. One of the goals of many social media sites is to “connect” a person with a person or place that she might be interested in. Imagine a girl by the name of Samantha that has seven friends on a social media site such as Facebook. These sites try to connect people to other people that they may know or have interest in. They do this by giving friend recommendations. These recommended friends are people that Samantha is not connected with on Facebook, but with whom many of her Facebook friends are connected to. Facebook “thinks” that if several of Samantha’s friends are all friends with a certain person, then perhaps Samantha might know this person also and want to become Facebook friends with her or him. This situation can be modeled with the following graph and pseudocode.

Graph:

Pseudocode:
If a stranger is friends with more than two of Samantha’s friends, suggest to Samantha that she becomes friends with that stranger. If the stranger is friends with two or less of Samantha’s friends, do not suggest that Samantha become friends with that stranger.

Samantha would be asked if she would like to become friends with Stranger 1, but not with Stranger 2. Of course, this is not exactly how Facebook’s algorithm reads, but it is likely somewhere along these lines.

Graph Theory Games
Analyzing graph theory can get complicated fairly quickly, but there are quite a few fun games that we can play that involve this branch of mathematics. One such game is called Sprouts. It was invented by John H. Conway and Michael S. Peterson both at the University of Cambridge in the United Kingdom. Possibly because it can be enjoyed by children on up through highly analytical adults, Sprouts quickly became a popular game.

What to give Sprouts a try? Grab a pencil, paper, and a friend. Draw as many dots as you like on the paper (between 3 and 6 is good for the first round). We will use four dots in our example:

The first player starts by connecting any two dots. She could also choose to draw a loop that starts and ends on the same dot. The two images below show valid moves.

The first player then makes a new dot somewhere toward the middle of the line/curve she just drew (it doesn’t matter exactly where).

Now it is the other player’s turn to connect two dots (or loop around one dot), and place a new dot toward the middle of the connecting line. Play continues as such, with just two rules:

  • A dot can never have more than three lines attached to it
  • Lines are never allowed to cross one another.

Here are possible moves for the next three plays:

The last person who is able to draw a line between dots without crossing another line or exceeding three lines attached to any one dot wins.

After continuing our example for quite a few rounds, we are left with the following situation in which there are no more possible plays.

When we play Sprouts, we are actually creating a graph. And just as graphs made from nodes and edges help software engineers analyze a problem, we can analyze our game. For example, we might wonder if it is possible to make a game of Sprouts continue on forever without an end.

To answer this think about a relatively small game of Sprouts that starts with two nodes.

Each node has the possibility of connecting to three edges.

But once we connect the two dots with one edge, we eliminate two of our six original moves.
Next we add a new node to our connection. This node is already connected to two nodes, so it has just one more connection left.

All in all, after our first move, we have eliminated two possible moves and added one new move, leaving a total of one less move than we started with. This continues as the game is played, with each move reducing the total possible number of moves by one. Since we start with a given number of possible connections and reduce that number by a total of one with each move, eventually the game must end. We can use similar approaches to figure out the most possible moves in a game, the least possible moves, and even whether the first or second player has an advantage.

Sprouts is one of many fun games that have a foundation in graph theory. Games such as Ticket to Ride, Settlers of Catan, Hex, and Sim (a pencil and paper game) can all be represented and analyzed using graph theory. Want to learn more? Take a look at some of the great sites linked below!

Learn More

Sim

https://en.wikipedia.org/wiki/Sim_%28pencil_game%29

Downloadable Graph Theory Games

https://www.tes.com/teaching-resource/graph-theory-puzzles-and-games-12164908

Sprouts

http://pi.math.cornell.edu/~mec/2003-2004/graphtheory/sprouts/howtoplaysprouts.html

Graph Theory Games

https://open.ed.ac.uk/graph-theory-puzzles-and-games/

Graph Theory

https://www.youtube.com/watch?v=ZQY4IfEcGvM

Graph Theory Applications

https://www.britannica.com/topic/graph-theory

Koenigsberg

https://medium.com/brandons-computer-science-notes/graph-theory-3bd99b24fa2a

Example of graph theory

https://www.freecodecamp.org/news/i-dont-understand-graph-theory-1c96572a1401/

Beanz Konigsberg

https://www.kidscodecs.com/7-bridges-konigsberg/

Beanz Graph Theory

https://www.kidscodecs.com/graph-theory/

How to play Sprouts

https://www.gamesforyoungminds.com/blog/2019/9/26/sprouts

(Visited 15 times, 1 visits today)

Also In The October 2020 Issue

Meet one of modern mathematics greatest contributors, Leonhard Euler!

How can we apply the Konigsberg Bridge problem to real life and even make a game out of it? With Sprouts of course!

Wi-Fi is a weird word for sure! But what does it really mean?

Learn how Eugene Kaspersky turned his antivirus making hobby into so much more!

What in the world is a video redundancy? Find out that and more in this crash course on encoding!

Links from the bottom of all the October 2020 articles, collected in one place for you to print, share, or bookmark.

Interesting stories about computer science, software programming, and technology for October 2020.

One of the first female programmers, Grace Hopper also worked as a mathematician and had an unusual career for women in the 1900s.

Need help proving your sibling has been sneaking into your room? This may be the perfect craft for you!

Bogons are not an evil race of aliens. But they do shine a light on one part of the internet little known outside of a few security technologists.