Subsection Section Preview
Investigate!
In the time of Euler, in the town of Königsberg in Prussia, there was a river containing two islands. The islands were connected to the banks of the river by seven bridges (as seen below). The bridges were very beautiful, and on their days off, townspeople would spend time walking over the bridges. As time passed, a question arose: Was it possible to plan a walk so that you cross each bridge once and only once? Euler was able to answer this question. Are you?
Graph Theory is a relatively new area of mathematics, first studied by the super famous mathematician Leonhard Euler in 1735. Since then it has blossomed into a powerful tool used in nearly every branch of science and is currently an active area of mathematics research.
The problem above, known as the
Seven Bridges of Königsberg, is the problem that originally inspired graph theory. Consider a “different” problem: Below is a drawing of four dots connected by some lines. Is it possible to trace over each line once and only once (without lifting your pencil, starting and ending on a dot)?
There is an obvious connection between these two problems. Any path in the dot and line drawing corresponds exactly to a path over the bridges of Königsberg.
Pictures like this dot and line drawing are called
graphs (although technically, the picture above is a
multigraph). Graphs are made up of a collection of dots called
vertices and lines connecting those dots called
edges. When two vertices are connected by an edge, we say they are
adjacent. The nice thing about looking at graphs instead of pictures of rivers, islands, and bridges is that we now have a mathematical object to study. We have distilled the “important” parts of the bridge picture for the problem. It does not matter how big the islands are, what the bridges are made out of, if the river contains alligators, etc. All that matters is which land masses are connected to which other land masses, and how many times. This was the great insight Euler had.
We will return to the question of finding paths through graphs in
Section 2.4. In this section, we will explore various ways that graphs can be used to represent, or
model, real-world problems. Along the way, we will introduce some basic definitions, terminology, and notation that will be used in the rest of the chapter.
Worksheet Preview Activity
To get a feel for graphs and the types of questions we want to ask about them, let’s explore four examples of graphs.
The graph
is presented as an
adjacency list where each vertex gets a list of which other vertices it is adjacent to. The graph
is presented as an
adjacency matrix where the rows and columns correspond to the vertices and the entries are 1 if the vertices are adjacent and 0 otherwise. Before answering the questions below, it might be helpful to draw a more traditional representation of these graphs.
1.
2.
3.
4.
5.
Subsection What is a Graph?
Before we start studying graphs, we need to agree upon what a graph is. While we almost always think of graphs as pictures (dots connected by lines), this is fairly ambiguous. Do the lines need to be straight? Does it matter how long the lines are or how large the dots are? Can there be two lines connecting the same pair of dots? Can one line connect three dots?
The way we avoid ambiguities in mathematics is to provide concrete and rigorous
definitions. Crafting good definitions is not easy, but it is incredibly important. The definition is the agreed-upon starting point from which all truths in mathematics proceed. Is there a graph with no edges? We have to look at the definition to see if this is possible.
We want our definition to be precise and unambiguous, but it also must agree with our intuition for the objects we are studying. It needs to be useful: We
could define a graph to be a six-legged mammal, but that would not let us solve any problems about bridges. Instead, here is the (now) standard definition of a graph.
Definition 2.1.1. Graph.
A
graph is an ordered pair
consisting of a nonempty set
(called the
vertices) and a set
(called the
edges) of two-element subsets of
Strange. Nowhere in the definition is there talk of dots or lines. From the definition, a graph could be
Here we have a graph with four vertices (the letters
) and five edges (the pairs
).
Looking at sets and sets of 2-element sets is difficult to process. That is why we often draw a representation of these sets. We put a dot down for each vertex, and connect two dots with a line precisely when those two vertices are one of the 2-element subsets in our set of edges. Thus one way to draw the graph described above is this:
However we could also have drawn the graph differently. For example either of these:
We should be careful about what it means for two graphs to be “the same.” Actually, given our definition, this is easy: Are the vertex sets equal? Are the edge sets equal? We know what it means for sets to be equal, and graphs are nothing but a pair of two special sorts of sets.
Example 2.1.2.
Are the graphs below equal?
Solution.
No. Here the vertex sets of each graph are equal, which is a good start. Also, both graphs have two edges. In the first graph, we have edges and while in the second graph we have edges and Of course, so that is not the problem. The issue is that Since the edge sets of the two graphs are not equal (as sets), the graphs are not equal (as graphs).
Even if two graphs are not
equal, they might be
basically the same. The graphs in the previous example could be drawn like this:
Graphs that are basically the same (but perhaps not equal) are called
isomorphic. We will give a precise definition of this term after a quick example:
Example 2.1.3.
Are these graphs the same?
Solution.
The two graphs are NOT equal. It is enough to notice that since but However, both of these graphs consist of three vertices with edges connecting every pair of vertices. We can draw them as follows:
Clearly we want to say these graphs are basically the same, so while they are not equal, they will be isomorphic. We can rename the vertices of one graph and get the second graph as the result.
Intuitively, graphs are
isomorphic if they are basically the same, or better yet, if they are the same except for the names of the vertices. To make the concept of renaming vertices precise, we give the following definitions:
Definition 2.1.4.
An
isomorphism between two graphs
and
is a bijection
between the vertices of the graphs such that
is an edge in
if and only if
is an edge in
Two graphs are
isomorphic if there is an isomorphism between them. In this case we write
An isomorphism is simply a function which renames the vertices. It must be a bijection so every vertex gets a new name. These newly named vertices must be connected by edges precisely when they were connected by edges with their old names.
Example 2.1.5.
Decide whether the graphs
and
are equal or isomorphic.
Solution.
The graphs are NOT equal, since but However, since both graphs contain the same number of vertices and the same number of edges, they might be isomorphic (this is not enough in most cases, but it is a good start).
We can try to build an isomorphism. How about we say and This is definitely a bijection, but to make sure that the function is an isomorphism, we must make sure it respects the edge relation. In vertices and are connected by an edge. In and are connected by an edge. So far, so good, but we must check the other three edges. The edge in corresponds to but here we have a problem. There is no edge between and in Thus is NOT an isomorphism.
Not all hope is lost, however. Just because is not an isomorphism does not mean that there is no isomorphism at all. We can try again. At this point it might be helpful to draw the graphs to see how they should match up.
Alternatively, notice that in the vertex is adjacent to every other vertex. In there is also a vertex with this property: So build the bijection by defining to start with. Next, where should we send In the vertex is only adjacent to vertex There is exactly one vertex like this in namely So let As for the last two, in this example, we have a free choice: let and (switching these would be fine as well).
We should check that this really is an isomorphism. It is definitely a bijection. We must make sure that the edges are respected. The four edges in are
Under the proposed isomorphism these become
which are precisely the edges in Thus is an isomorphism, so
Sometimes we will talk about a graph with a special name (like
or the
Petersen graph) or perhaps draw a graph without any labels. In this case, we are really referring to
all graphs isomorphic to any copy of that particular graph. A collection of isomorphic graphs is often called an
isomorphism class.
There are other relationships between graphs that we care about, other than equality and being isomorphic. For example, compare the following pair of graphs:
These are definitely not isomorphic, but notice that the graph on the right looks like it might be part of the graph on the left, especially if we draw it like this:
We would like to say that the smaller graph is a
subgraph of the larger.
We should give a careful definition of this. In fact, there are two reasonable notions for what a subgraph should mean.
Definition 2.1.6. Subgraphs.
We say that
is a
subgraph of
and write
provided
and
We say that
is an
induced subgraph of
provided
and every edge in
whose vertices are still in
is also an edge in
Notice that every induced subgraph is also an ordinary subgraph, but not conversely. Think of a subgraph as the result of deleting some vertices and edges from the larger graph. For the subgraph to be an induced subgraph, we can still delete vertices, but now we only delete those edges that included the deleted vertices.
Example 2.1.7.
Here both
and
are subgraphs of
But only
is an
induced subgraph. Every edge in
that connects vertices in
is also an edge in
In
the edge
is in
but not
even though vertices
and
are in
The graph
is NOT a subgraph of
even though it looks like all we did is remove vertex
The reason is that in
we have the edge
but this is not an element of
so we don’t have the required
Back to some basic graph theory definitions. Notice that all the graphs we have drawn above have the property that no pair of vertices is connected more than once, and no vertex is connected to itself. Graphs like these are sometimes called
simple, although we will just call them
graphs. This is because our definition of a graph says that the edges form a set of 2-element subsets of the vertices. Remember that it doesn’t make sense to say a set contains an element more than once. So no pair of vertices can be connected by an edge more than once. Also, since each edge must be a set containing two vertices, we cannot have a single vertex connected to itself by an edge.
That said, there are times we want to consider double (or more) edges and single-edge loops. For example, the “graph” we drew for the Bridges of Königsberg problem had double edges because there really are two bridges connecting a particular island to the near shore. We will call these objects
multigraphs. This is a good name: A
multiset is a set in which we are allowed to include a single element multiple times.
The graphs above are also
connected: you can get from any vertex to any other vertex by following some path of edges. A graph that is not connected can be thought of as two separate graphs drawn close together. For example, the following graph is NOT connected because there is no path from
to
Vertices in a graph do not always have edges between them. If we add all possible edges, then the resulting graph is called
complete. That is, a graph is complete if every pair of vertices is connected by an edge. Since a graph is determined completely by which vertices are adjacent to which other vertices, there is only one complete graph with a given number of vertices. We give these a special name:
is the complete graph on
vertices.
Each vertex in
is adjacent to
other vertices. We call the number of edges emanating from a given vertex the
degree of that vertex. So every vertex in
has degree
How many edges does
have? One might think the answer should be
since we count
edges
times (once for each vertex). However, each edge is incident to 2 vertices, so we counted every edge exactly twice. Thus there are
edges in
Alternatively, we can say there are
edges, since to draw an edge we must choose 2 of the
vertices.
In general, if we know the degrees of all the vertices in a graph, we can find the number of edges. The sum of the degrees of all vertices will always be
twice the number of edges, since each edge adds to the degree of two vertices. Notice this means that the sum of the degrees of all vertices in any graph must be even!
This is our first example of a general result about all graphs. It seems innocent enough, but we will use it to prove all sorts of other statements. So let’s give it a name and state it formally.
Lemma 2.1.8. Handshake Lemma.
In any graph, the sum of the degrees of vertices in the graph is always twice the number of edges.
The handshake lemma is sometimes called the
degree sum formula, and can be written symbolically as
Here we are using the notation
for the degree of the vertex
One use for the lemma is to actually find the number of edges in a graph. To do this, you must be given the
degree sequence for the graph (or be able to find it from other information). This is a list of every degree of every vertex in the graph, generally written in non-increasing order.
Example 2.1.9.
How many vertices and edges must a graph have if its degree sequence is
Solution.
The number of vertices is easy to find. It is the number of degrees in the sequence: 7. To find the number of edges, we compute the degree sum
so the number of edges is half this: 10.
The handshake lemma also tells us what is not possible.
Example 2.1.10.
At a recent math seminar, 9 mathematicians greeted each other by shaking hands. Is it possible that each mathematician shook hands with exactly 7 people at the seminar?
Solution.
It seems like this should be possible. Each mathematician chooses one person to not shake hands with. But this cannot happen. We are asking whether a graph with 9 vertices can have each vertex have degree 7. If such a graph existed, the sum of the degrees of the vertices would be This would be twice the number of edges (handshakes) resulting in a graph with edges. That is impossible. Thus at least one (in fact an odd number) of the mathematicians must have shaken hands with an even number of people at the seminar.
We can generalize the previous example to get the following proposition.
Proposition 2.1.11.
In any graph, the number of vertices with odd degree must be even.
Proof.
Suppose there were a graph with an odd number of vertices with odd degree. Then the sum of the degrees in the graph would be odd, which is impossible, by the handshake lemma.
We will consider further applications of the handshake lemma in the exercises.
One final definition: We say a graph is
bipartite if the vertices can be divided into two sets,
and
with no two vertices in
adjacent and no two vertices in
adjacent. The vertices in
can be adjacent to some or all of the vertices in
If each vertex in
is adjacent to all the vertices in
then the graph is a
complete bipartite graph, and gets a special name:
where
and
Named Graphs.
Some graphs are used more than others and get special names.
The complete graph on
vertices.
The complete bipartite graph with sets of
and
vertices.
The cycle on
vertices, just one big loop.
The path on
vertices (so
edges), just one long path.
Graph Theory Definitions.
There are a lot of definitions to keep track of in graph theory. Here is a glossary of the terms we have already used and will soon encounter.
- Graph
A collection of
vertices, some of which are connected by
edges. More precisely, a pair of sets
and
where
is a set of vertices and
is a set of 2-element subsets of
- Adjacent
Two vertices are
adjacent if they are connected by an edge. Two edges are
adjacent if they share a vertex.
- Bipartite graph
A graph for which it is possible to divide the vertices into two disjoint sets such that there are no edges between any two vertices in the same set.
- Complete bipartite graph
A bipartite graph for which every vertex in the first set is adjacent to every vertex in the second set.
- Complete graph
A graph in which every pair of vertices is adjacent.
- Connected
A graph is
connected if there is a path from any vertex to any other vertex.
- Chromatic number
The minimum number of colors required in a proper vertex coloring of the graph.
- Cycle
A path (see below) that starts and stops at the same vertex, but contains no other repeated vertices.
- Degree of a vertex
The number of edges incident to a vertex.
- Euler trail
A walk which uses each edge exactly once.
- Euler circuit
An Euler trail which starts and stops at the same vertex.
- Multigraph
A
multigraph is just like a graph but can contain multiple edges between two vertices as well as single edge loops (that is an edge from a vertex to itself).
- Path
A
path is a walk that doesn’t repeat any vertices (or edges) except perhaps the first and last. If a path starts and ends at the same vertex, it is called a
cycle.
- Planar
A graph which can be drawn (in the plane) without any edges crossing.
- Subgraph
We say that
is a
subgraph of
if every vertex and edge of
is also a vertex or edge of
We say
is an
induced subgraph of
if every vertex of
is a vertex of
and each pair of vertices in
are adjacent in
if and only if they are adjacent in
.
- Tree
A connected graph with no cycles. (If we remove the requirement that the graph is connected, the graph is called a
forest.) The vertices in a tree with degree 1 are called
leaves.
- Vertex coloring
An assignment of colors to each of the vertices of a graph. A vertex coloring is
proper if adjacent vertices are always colored differently.
- Walk
A sequence of vertices such that consecutive vertices (in the sequence) are adjacent (in the graph). A walk in which no edge is repeated is called a
trail, and a trail in which no vertex is repeated (except possibly the first and last) is called a
path.