## A Whimsical Introduction to Graph Theory (1)

Part 1 – What are Graphs?

Mathematics is full of fascinating ideas and concepts. These can, however, be very challenging to tackle and make sense of, especially when you are put under pressure to answer questions about them! In this post, and those to come, I hope to share some insight into these concepts without getting too formal. Where some definitions and more technical bits are introduced, they will be explained at end of the post: look out for the dagger $\dagger$ symbols!

To begin, let’s ask what we do in mathematics. The first step in any area of maths is almost always to abstract things. We take some concept we want to be able to work with and pull out the essential ideas. From a bunch of maps we may take out just destinations and the routes between them; from 3D objects we may only need to know what ways we can rotate them and still see the same thing; from a collection of algorithms we may only care about how long they take to run on a computer, and so on.…

## Graph Theory, Numberphile and Mathematica

Edit: I made a mistake with some of the language here. A comment from a true graph theorist:

“Hamiltonian” usually means there’s a hamilton/hamiltonian cycle. Graphs with a hamilton path are “traceable”. Hamiltonian implies traceable, but not conversely.

Thus, I have edited below accordingly.

——————————-

There was a nice video up on Numberphile about a problem which could easily be explained to a school student, and yet we don’t yet know the answer to it. See the videos here:

and

The game is the following: Given a sequence of consecutive integers, draw a graph where the nodes are the integers and there is an edge between each integer if their sum is a square number.

If we take the numbers from 1 to 12, then the following would be the associated graph (note that there are three disconnected pieces of it).

Note that this is a disconnected, undirected graph. Looking at some of the edges.…

## Mathematica details of the cooking with mathematics post

Edit: If you want to see the full code, I include everything in this post in the Mathematica file here.

I promised previously that we would go into depth into the graph theory and food calculations, so today we will do just that. This will be Mathematica heavy, so really this is only aimed at those who have played around with the Mathematica programming language.

I’ve been using this language now for over a decade, and while it is not the fastest language on the market for doing numerics-heavy calculations, it is an incredibly versatile language, and for getting code written fast, it’s hard to beat!

I tend to code in what is called a functional programming style (ideal for Mathematica), which doesn’t use loops as you would normally find in a procedural language. Perhaps the most oft used coding syntax you will see below is of the form:

somefunction[#]&/@{el1,el2,el3,el4…}

which takes the elements of a list and passes them one by one into a function.…

## Cooking with Mathematics

This post is not going to be very maths-heavy but will include some concepts from the area of graph theory which we will use in an unusual setting.

Today we’re going to get into the virtual kitchen and get our virtual taste buds a-buzzing….Well, actually we’re going to get our computers to do the hard work of finding out some tasty recipes and we’re going to use a few different techniques to do this. The workhorse is going to be the Mathematica programming language, but a lot of what we will do will be doable in any programming language, though perhaps it will be slightly more cumbersome than this.

The starting point of our culinary adventure will be a piece of text, taken from a website of flavour pairings here.

We see here that we have a piece of text which we can copy and paste into our Mathematica file.…