Login
📚 Discrete Mathematics
Chapters ▾
⇩ Download ▾

5.1 Definitions

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.

Strange. Nowhere in the definition is there talk of dots or lines. From the definition, a graph could be

( { a , b , c , d } , { { a , b } , { a , c } , { b , c } , { b , d } , { c , d } } )

. Here we have a graph with four vertices (the letters a , b , c , d ) and five edges (the pairs { a , b } , { a , c } , { b , c } , { b , d } , { c , d } ) ).

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:

Four vertices arranged in a square, with edges on the border of the square and one connecting the bottom left vertex to the top right vertex. Vertices are labeled a (top left), b (top right), c (bottom left) and d (bottom right).

However we could also have drawn the graph differently. For example either of these:

Four vertices arranged in a square. Vertices are labeled a (top left), d (top right), c (bottom left) and b (bottom right). Edges connect a to c and b, d to b and c, and c to b.
Four vertices arranged in a horizontal row, labeled a, b, c, and d from left to right. Edges connect each vertex to the one on its right. A curved edge connects a to c, and another curved edge connects b to d.

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.

Even if two graphs are not equal, they might be basically the same. The graphs in the previous example could be drawn like this:

Two graphs with three vertices each arranged in a horizontal row. Edges connect vertices to the vertex on either side of it. The graph on the left (G1) has vertices labeled a, b, c from left to right. The graph on the right (G2) has vertices labeled a, c, b from left to right.

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:

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:

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.

Sometimes we will talk about a graph with a special name (like K n 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. 1

There are other relationships between graphs that we care about, other than equality and being isomorphic. For example, compare the following pair of graphs:

A graph with six vertices arranged in a hexagon, with edges between every possible pair of vertices.
Four vertices arranged in a diamond, with edges between every possible pair of vertices.

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:

A graph with six vertices arranged in a hexagon with edges between every pair of vertices. Six edges are drawn in bold, forming a slanted rectangle with an X through it.

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.

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.

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 for 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 a to b :

A graph consisting of eight vertices arranged in two overlapping diamonds, with edges forming the border of those diamonds. The vertex on the far left is labeled a and the vertex on the far right is labeled b.

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: K n is the complete graph on n vertices.

Each vertex in K n is adjacent to n 1 other vertices. We call the number of edges emanating from a given vertex the degree of that vertex. So every vertex in K n has degree n 1 . How many edges does K n have? One might think the answer should be n ( n 1 ) , since we count n 1 edges n times (once for each vertex). However, each edge is incident to 2 vertices, so we counted every edge exactly twice. Thus there are n ( n 1 ) / 2 edges in K n . Alternatively, we can say there are ( n 2 ) edges, since to draw an edge we must choose 2 of the n 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.

The handshake lemma2 is sometimes called the degree sum formula, and can be written symbolically as

v V d ( v ) = 2 e

. Here we are using the notation d ( v ) for the degree of the vertex v .

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.

The handshake lemma also tells us what is not possible.

We can generalize the previous example to get the following proposition.3

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, A and B , with no two vertices in A adjacent and no two vertices in B adjacent. The vertices in A can be adjacent to some or all of the vertices in B . If each vertex in A is adjacent to all the vertices in B , then the graph is a complete bipartite graph, and gets a special name: K m , n , where | A | = m and | B | = n . The graph in the houses and utilities puzzle is K 3 , 3 .

Named Graphs

Some graphs are used more than others, and get special names.

  • K n
    The complete graph on n vertices.
  • K m , n
    The complete bipartite graph with sets of m and n vertices.
  • C n
    The cycle on n vertices, just one big loop.
  • P n
    The path on n + 1 vertices (so n edges), just one long path.
The graph K5: five vertices arranged in a pentagon. Each vertex is connected to each other vertex by an edge.
The graph K2,3: a row of two vertices on top and three on bottom. Each vertex in the top row is connected to each vertex on the bottom row.
The graph C6: a cycle of six vertices connected by six edges arranged as a hexagon.
The graph P5: six vertices connected by five edges. The first and last vertex have one edge, each other vertex has two edges (connecting to the previous and next vertex on the 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 V and E where V is a set of vertices and E is a set of 2-element subsets of V .
  • 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 path
    A walk which uses each edge exactly once.
  • Euler circuit
    An Euler path 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 H is a subgraph of G if every vertex and edge of H is also a vertex or edge of G . We say H is an induced subgraph of G if every vertex of H is a vertex of G and each pair of vertices in H are adjacent in H if and only if they are adjacent in G .
  • 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.

If 10 people each shake hands with each other, how many handshakes took place? What does this question have to do with graph theory?

This is asking for the number of edges in K 10 . Each vertex (person) has degree (shook hands with) 9 (people). So the sum of the degrees is 90 . However, the degrees count each edge (handshake) twice, so there are 45 edges in the graph. That is how many handshakes took place.

Among a group of 5 people, is it possible for everyone to be friends with exactly 2 of the people in the group? What about 3 of the people in the group?

It is possible for everyone to be friends with exactly 2 people. You could arrange the 5 people in a circle and say that everyone is friends with the two people on either side of them (so you get the graph C 5 ). However, it is not possible for everyone to be friends with 3 people. That would lead to a graph with an odd number of odd degree vertices which is impossible since the sum of the degrees must be even.

Is it possible for two different (non-isomorphic) graphs to have the same number of vertices and the same number of edges? What if the degrees of the vertices in the two graphs are the same (so both graphs have vertices with degrees 1, 2, 2, 3, and 4, for example)? Draw two such graphs or explain why not.

Both situations are possible. Go find some examples.

Are the two graphs below equal? Are they isomorphic? If they are isomorphic, give the isomorphism. If not, explain.

Graph 1: V = { a , b , c , d , e } , E = { { a , b } , { a , c } , { a , e } , { b , d } , { b , e } , { c , d } } .

Graph 2:

A graph with five vertices arranged in a pentagon, labeled a through e, starting with the vertex at the top and proceeding counterclockwise. Edges between vertices a, c, and d make a triangle. Edges between b, c, d, and e form a quadralateral.

The graphs are not equal. For example, graph 1 has an edge { a , b } but graph 2 does not have that edge. They are isomorphic. One possible isomorphism is f : G 1 G 2 defined by f ( a ) = d , f ( b ) = c , f ( c ) = e , f ( d ) = b , f ( e ) = a .

Consider the following two graphs:

  • G 1
    V 1 = { a , b , c , d , e , f , g }
    E 1 = { { a , b } , { a , d } , { b , c } , { b , d } , { b , e } , { b , f } , { c , g } , { d , e } ,
    { e , f } , { f , g } } .
  • G 2
    V 2 = { v 1 , v 2 , v 3 , v 4 , v 5 , v 6 , v 7 } ,
    E 2 = { { v 1 , v 4 } , { v 1 , v 5 } , { v 1 , v 7 } , { v 2 , v 3 } , { v 2 , v 6 } ,
    { v 3 , v 5 } , { v 3 , v 7 } , { v 4 , v 5 } , { v 5 , v 6 } , { v 5 , v 7 } }
  1. Let f : G 1 G 2 be a function that takes the vertices of Graph 1 to vertices of Graph 2. The function is given by the following table:
    x a b c d e f g
    f ( x ) v 4 v 5 v 1 v 6 v 2 v 3 v 7

    Does f define an isomorphism between Graph 1 and Graph 2?
  2. Define a new function g (with g f ) that defines an isomorphism between Graph 1 and Graph 2.
  3. Is the graph pictured below isomorphic to Graph 1 and Graph 2? Explain.
    A graph with seven vertices. Six of the vertices are arranged in rectangle, three across and two down, with edges around the perimeter. The seventh vertex is in the center, with edges connecting it to the vertices directly above and below it, and to the two outside vertices in the bottom row.

What is the largest number of edges possible in a graph with 10 vertices? What is the largest number of edges possible in a bipartite graph with 10 vertices? What is the largest number of edges possible in a tree with 10 vertices?

The bipartite graph is a little tricky. You will definitely want a complete bipartite graph, but it could be K 5 , 5 or maybe K 1 , 9 , or …

Which of the graphs below are bipartite? Justify your answers.

A graph with five vertices. Four vertices make up the corners of a diamond; the last vertex is in the center. Edges form the perimeter of the diamond and connect the center vertex to the two corners on the left and right.
A graph consisting of six vertices arranged in a hexagon. Edges connect each vertex to two others, but not in a cycle around the outside of the hexagon. However, following along the edges does visit every vertex.
A graph consisting of seven vertices arranged in a seven-sided polygon, with edges forming the perimeter of the polygon.
A graph consisting of a single vertex with eight edges connecting to eight vertices arranged in a circle around the central vertex.

The first graph is bipartite, which can be seen by labeling it as follows.

A graph with five vertices. Four vertices make up the corners of a diamond; the last vertex is in the center. Edges form the perimeter of the diamond and connect the center vertex to the two corners on the left and right. The vertices on left and right are labeled A, the three vertices in the center column are each labeled B.

Two of the remaining three are also bipartite.

For which n 3 is the graph C n bipartite?

C 4 is bipartite; C 5 is not. What about all the other values of n ?

For each of the following, try to give two different unlabeled graphs with the given properties, or explain why doing so is impossible.

  1. Two different trees with the same number of vertices and the same number of edges. A tree is a connected graph with no cycles.
  2. Two different graphs with 8 vertices all of degree 2.
  3. Two different graphs with 5 vertices all of degree 4.
  4. Two different graphs with 5 vertices all of degree 3.
  1. For example:
    A graph consisting of a vertex with three edges connecting it to three vertices in a row above it.
    A graph consisting of four vertices arranged in a V. The left point of the V connects to the bottom corner of the V. That vertex is connected to a vertex half way up the right side of the V, which is then connected to the vertex at the right point of the V.
  2. This is not possible if we require the graphs to be connected. If not, we could take C 8 as one graph and two copies of C 4 as the other.
  3. Not possible. If you have a graph with 5 vertices all of degree 4, then every vertex must be adjacent to every other vertex. This is the graph K 5 .
  4. This is not possible. In fact, there is not even one graph with this property (such a graph would have 5 3 / 2 = 7.5 edges).

Decide whether the statements below about subgraphs are true or false. For those that are true, briefly explain why (1 or 2 sentences). For any that are false, give a counterexample.

  1. Any subgraph of a complete graph is also complete.
  2. Any induced subgraph of a complete graph is also complete.
  3. Any subgraph of a bipartite graph is bipartite.
  4. Any subgraph of a tree is a tree.
  1. False.
  2. True.
  3. True.
  4. False.

Let k 1 , k 2 , , k j be a list of positive integers that sum to n (i.e., i = 1 j k i = n ). Use two graphs containing n vertices to explain why

i = 1 j ( k i 2 ) ( n 2 )

.

How many edges does K n have? One of the two graphs will not be connected (unless j = 1 ).

We often define graph theory concepts using set theory. For example, given a graph G = ( V , E ) and a vertex v V , we define

N ( v ) = { u V : { v , u } E }

. We define N [ v ] = N ( v ) { v } . The goal of this problem is to figure out what all this means.

  1. Let G be the graph with V = { a , b , c , d , e , f } and E = { { a , b } , { a , e } , { b , c } , { b , e } , { c , d } , { c , f } , { d , f } , { e , f } } . Find N ( a ) , N [ a ] , N ( c ) , and N [ c ] .
  2. What is the largest and smallest possible values for | N ( v ) | and | N [ v ] | for the graph in part (a)? Explain.
  3. Give an example of a graph G = ( V , E ) (probably different than the one above) for which N [ v ] = V for some vertex v V . Is there a graph for which N [ v ] = V for all v V ? Explain.
  4. Give an example of a graph G = ( V , E ) for which N ( v ) = for some v V . Is there an example of such a graph for which N [ u ] = V for some other u V as well? Explain.
  5. Describe in words what N ( v ) and N [ v ] mean in general.

You should be able to deduce everything directly from the definition. However, perhaps it would be helpful to know that the N stands for neighborhood.

A graph is a way of representing the relationships between elements in a set: an edge between the vertices x and y tells us that x is related to y (which we can write as x y ). Not all sorts of relationships can be represented by a graph though. For each relationship described below, either draw the graph or explain why the relationship cannot be represented by a graph.

  1. The set V = { 1 , 2 , , 9 } and the relationship x y when x y is a non-zero multiple of 3.
  2. The set V = { 1 , 2 , , 9 } and the relationship x y when y is a multiple of x .
  3. The set V = { 1 , 2 , , 9 } and the relationship x y when 0 < | x y | < 3 .

Be careful to make sure the edges are not “directed.” In a graph, if a is adjacent to b , then b is adjacent to a . In the language of relations, we say that the edge relation is symmetric.

Consider graphs with n vertices. Remember, graphs do not need to be connected.

  1. How many edges must the graph have to guarantee at least one vertex has degree two or more? Prove your answer.
  2. How many edges must the graph have to guarantee all vertices have degree two or more? Prove your answer.

You might want to answer the questions for some specific values of n to get a feel for them, but your final answers should be in terms of n .

Prove that any graph with at least two vertices must have two vertices of the same degree.

Try a small example first: any graph with 8 vertices must have two vertices of the same degree. If not, what would the degree sequence be?

Suppose G is a connected graph with n > 1 vertices and n 1 edges. Prove that G has a vertex of degree 1.

Use the handshake lemma. What would happen if all the vertices had degree 2?

Discrete Mathematics: An Open Introduction, 3rd edition, by Oscar Levin (discrete.openmathbooks.org), licensed under CC BY-SA 4.0; this adaptation is distributed under the same license. License: CC-BY-SA-4.0.