History is important, any history major will tell you that. Graph Theory was created by the famous mathematician Euler when he attempted to solve a problem involving some bridges. He wanted to know if someone could start somewhere in a town, walk across every bridge exactly once, and return to the start. To do this problem he used the notion of paths, cycles, and degrees.
First, two vertices are said to be adjacent if there is an edge connecting them. A path from one vertex to another vertex is a list of the labels in an order which specifies which edges to go along. Obviously to go from one vertex to another, they have to be adjacent. For example, if we have some graph,
then a path from A to E could be written as ACDE. Another path would be ABE, and yet another would be ABCDE. The length of a path is the number of edges that it has. So the length of ACDE would be 3. With the idea of length we can ask what the shortest path between two points is, and how do we find it in general for any graph? This actually takes a lot more work to solve, so moving on.
A closed path is a path that starts and ends at the same place, so in the example above, DBACBED would be a closed path starting and ending at D. An open path starts and ends at different vertices.
A cycle is a closed path without any repetitions (other than the starting point). For example ABCA is a cycle of length 3, while DBACBED is not a cycle since it goes through B twice.
The last simple concept for today will be the degree of a vertex. The degree of a vertex is the number of edges that touch the vertex. In the above example the degree of A would be 2, while the degree of B would be 4. Math people use the notation d(A) = 2, d(B)=4.
When the degree is an odd number, we call the vertex an odd vertex, and similarly an even vertex is a vertex with even degree.
We used this concept last time without specifically mentioning it by name to get the number of edges in a complete graph. In a complete graph with N vertices, every vertex will have degree N-1.
An Euler path is a path that goes through every edge exactly once. We can have closed or open Euler paths. The degree of a vertex is the important concept to use when finding out when an Euler path exists. For example the below graph
has no Euler paths at any vertices. However we can find an open Euler path in the next graph starting at D and ending at C:
I’ve marked the path by numerical order in the picture, but it would be written out as:
The reasoning that this graph has an Euler path but the other graph doesn’t is subtle and needs a few more tools first. One such tool is the following.
The Degree Theorem: In ANY graph the sum of the degrees of every vertex is equal to twice the number of edges. We did something similar for complete graphs, but this is for any graph and the reasoning is exactly the same.
Taking all the vertices and adding up all their degrees gives you a total number of edges, but again each edge is counted twice, once for each vertex that it touches, so this sum is equal to twice the number of edges. In fancy math notation we can write it like this:
where N is the number of edges, and are the k vertices of the graph where k is some finite number, and is the degree of the i’th vertex.
This theorem is the key to finding when Euler paths exist and I will use it next time to do that.