Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Math 145 Homework 6 Solutions

4
Problem 1. For a set V = {a, b, c, d}, there are 2(2) = 64 distinct graphs. How many unlabeled
graphs on 4 vertices are there? Draw each distinct graph on 4 vertices, and for each of your
cases write down how many distinct ways there are to assign labels a, b, c, d to the vertices (this
sum over all the cases should of course be 64).

Solution. There are 11 distinct ways, drawn here with the number of labelings below:

The edgeless graph has 1 labeling. There is a unique type of graph with 1 edge, and 6
4

labelings ( 2 to pick which labels are connected). There are two types of graphs with 2 edges.
The first has 12 labelings (4 ways to label the degree 2 vertex, then 3 ways to label the degree 0
vertex), the second has 3 labelings (pick which label gets paired with a). (Note that this gives
15 = 62 labeled graphs with 2 edges as expected).
There are three types of graphs with 3 edges. The first (the star S3 ), has 4 labelings (pick
the label for the unique vertex of degree 3). The second (the path P4 ) has 12 labelings (4!/2
since graph has a left/right reflection symmetry). The third has 4 labelings (pick the label for
the unique degree 0 vertex). (Note that this gives 20 = 63 labeled graphs with 3 edges as
expected).
The types of graphs with 4, 5, 6 edges are simply the complements of the types of graphs
with 2, 1, 0 edges, so we get 4 more types, with the same counts as above. We can verify that
we have a total of 64 labeled graphs.

Problem 2. The following figure shows four graphs G1 , G2 , G3 , G4 , all with 10 vertices.

1
Determine which pairs of graphs are isomorphic. If the graphs are isomorphic, write the
isomorphism (relabelling) between the two sets of vertices. If the graphs are not isomorphic,
prove why they aren’t (state some property that is different in the two graphs, and prove that
any relabelling of the vertices would preserve this property).

G1 : 1 2 3 4 5 6 7 8 9 10
Solution. G1 and G3 are isomorphic.
G3 : 1 2 3 8 9 10 4 5 6 7
The following shows the relabeling of G1 . We can verify that this is precisely the same graph
as G3 , since it has the exact same edge set.

G4 is not isomorphic to G1 (and thus also not isomorphic to G3 ), since G4 has a cycle of
length 4, and G1 does not have any cycles of length 4. Any relabeling of G4 would clearly still
contain a cycle of length 4.
G2 is not isomorphic to any of the other graphs, since it two vertices of degree 4, and the
other graphs do not have any vertices of degree 4. Any relabeling of G2 would clearly still
contain a vertex with degree 4. Another reason is that G2 contains 16 edges, while the other
graphs have 15.

Problem 3. In a connected graph G = (V, E), for two vertices v, w ∈ V , we define the distance
dist(v, w) to be the length of the shortest path containing v and w. We define the diameter of
G to be the maximal distance dist(v, w) over all pairs v, w ∈ V .
For the following graphs, give their degree sequence and their diameter. For example, for
the complete graph Kn , the degree sequence is n − 1, n − 1, . . . , n − 1 (degree n − 1 for all n
vertices), and the diameter is 1 since dist(v, w) = 1 for any v, w ∈ V , since {v, w} ∈ E.

1. The path Pn

2. The cycle Cn

3. The complete bipartite graph Kn,m

4. Graph G1 from Problem 2

Solution. The path Pn has degree sequence 1, 1, 2, 2, . . . , 2. The two vertices at the ends (v1
and vn ) clearly have the greatest distance, which is n − 1, so the diameter is n − 1.
The cycle Cn has degree sequence 2, 2, . . . , 2, since every vertex has degree 2. Between any
two vertices i < j, there is a path of length (j − i) and of length n − (j − i). The shorter of
these paths can be at most bn/2c, which is the diameter of Cn .
The complete bipartite graph has degree sequence m, . . . , m, n, . . . , n (n vertices ai of degree
m and m vertices bj of degree n). The diameter is 2, since every d(ai , bj ) = 1 for all i, j, and
d(ai , aj ) = 2 and d(bi , bj ) = 2 for all i, j.

2
Graph G1 above has degree sequence 3, 3, . . . , 3 since every vertex has degree 3. From vertex
1, we can verify that every other vertex is at distance at most 2 away. By symmmetry, this
holds for all other vertices, so the diameter is 2.

Problem 4. For any graph G = (V, E), prove that there must exist two vertices v, w ∈ V with
the same degree (d(v) = d(w)).

Solution. Let G have n vertices. Then for any vertex v, 0 ≤ d(v) ≤ n − 1. If there exists a
vertex of degree n − 1, it is connected to all other vertices, so there does not exist a vertex
of degree 0. Thus there are n − 1 possible degrees in each of these two cases 1, . . . , n − 1 or
0, . . . , n − 2. By Pidegonhole Principle, since each of n vertices is assigned one of n − 1 possible
degrees, there must exist two vertices with the same degree.

Problem 5. For any graph G = (V, E), prove that at least one of G and G is connected.

Solution. Without loss of generality, we will assume G is disconnected and show G is connected.
Since G is disconnected, there exist some disconnected v, w ∈ V (ie. there is no path from v
to w). Now we will show that G is connected, since for any x, y ∈ V , there is a path from x
to y using edges in E. First notice that {v, w} ∈ E since v and w are disconnected. Also, for
any x ∈ V {x, v} ∈ E or {x, w} ∈ E since if both were in E this would give a path of length 2
between v and w. Since this also holds for y, we now have a path between x and y using at most
3 edges in E (going through v, through w, or through v and then w). Thus G is connected.

Problem 6. (**) We saw in class that the path on 4 vertices and cycle on 5 vertices were each
isomorphic to their complement (P4 ' P4 and C5 ' C5 ). Are there other examples of graphs
with this property?
First prove that if G ' G, we must have |V | = 4k or |V | = 4k + 1.
Then for each k ∈ N, show how to construct a graph G with 4k vertices and G ' G.
Finally, show how to construct a graph G with 4k + 1 vertices and G ' G.

Solution. Let G = (V, E), with |V | = n. In order for G ' G, we must have |E| = |E|. Since
|E| + |E| = n2 , we must have n2 = n(n−1)
 
2 be even. This is clearly true if n = 4k or n = 4k + 1,
n
but if n = 4k + 2, we have 2 = (2k + 1)(4k + 1) which is odd, and if n = 4k + 3, we have
n

2 = (4k + 3)(2k + 1) which is odd.
We now give a general construction for such a G on n = 4k vertices. The following picture
shows the sketch of the idea, along with an additional vertex x that would give 4k + 1 vertices:

3
The vertices are partitioned into 4 groups of size k: V = A ∪ B ∪ C ∪ D, where A =
{a1 , . . . , ak },B = {b1 , . . . , bk },C = {c1 , . . . , ck }, and D = {d1 , . . . , dk }. We then add an edge
between any pair of vertices in group B or C, and also across any pair of vertices in group A
and B, and across any pair in group C and D. In particular,
E = {{v, w} : ∀v, w ∈ A ∪ B} ∪ {{a, b} : ∀a ∈ A, b ∈ B} ∪ {{c, d} : ∀c ∈ C, d ∈ D}
We can count that
   
2k 2 2 1 4k
|E| = + k + k = k(4k − 1) =
2 2 2
as desired. We can also consider the structure of E, the edges we did not include, and realize
that
E = {{v, w} : ∀v, w ∈ C ∪ D} ∪ {{a, c} : ∀a ∈ A, c ∈ B} ∪ {{b, d} : ∀b ∈ C, d ∈ D}
Thus G has the exact same structure if we swap the roles of A with B and C with D. In
particular, the isomorphism transposes ai and bi and transposes ci and di for all i.
Now we can modify this construction to give n = 4k + 1 vertices, by adding an additional
vertex x with edges to all b ∈ B and all c ∈ C. Then E contains edges between x and the
vertices in A and D, as desired.

Problem 7. (*) Let G = (V, E) be any graph on 6 vertices. Prove that at least one of G or G will
contain a triangle (K3 ) as a subgraph. In other words, if V = {v1 , v2 , v3 , v4 , v5 , v6 }, then show
that for some triple vi , vj , vk , either {vi , vj }, {vi , vk }, {vj , vk } ∈ E or {vi , vj }, {vi , vk }, {vj , vk } ∈
/
E.
Solution. We can equivalently describe this problem where the edges in E and E has two distinct
colors. Thus we have the complete graph K6 where every edge is red or blue, and we must show
there is a monochromatic triangle.
Consider an arbitrary vertex v1 . Then v1 has 5 edges, so by Pidegonhole Principle, there
are at least three edges of the same color, so without loss of generality there are red edges
to vi , vj , vk . Now if there is also a red edge between any of vi , vj , vk , this will create a red
triangle. If not, then vi , vj , vk will be the corners of a blue triangle. Thus there must exist a
monochromatic triangle.
Also note this wasn’t true for n = 5 vertices. The cycle C5 has no triangle (and its com-
plement is isomorphic, so also has no triangle). Thus 6 is the minimum number of vertices to
guarantee this property. This shows that the Ramsey number R(3, 3) = 6.
We can generalize this question: the Ramsey number R(j, k) asks for the minimal size of
a graph such that you are guaranteed to either find j vertices that are totally connected, or
k vertices that are totally disconnected. Surprisingly, this problem gets unsolved very quickly.
R(4, 4) = 18, but we already don’t know the value for R(5, 5) (although we have bounds
43 ≤ R(5, 5) ≤ 48.
https://en.wikipedia.org/wiki/Ramsey%27s_theorem
There are also some asymptotic bounds for R(k, k) for large k. The mathematician Paul
Erdős invented a technique called the probabilistic method to give a lower bound for R(k, k)
(ie. like we showed R(3, 3) > 5 because C5 did not have any monochromatic triangles). The
idea is to consider how likely it is to find a monochromatic k-clique in a random graph with
n vertices, and when the probability is less than 1, this means there exists some graph with n
vertices and no monochromatic k-clique (so even though we can’t construct the example, we can
show that it exists! See https://en.wikipedia.org/wiki/Probabilistic_method for more
details.)

4
Problem 8. In class (and in the text) we proved that a graph G has an closed Eulerian walk if
and only if G is connected and every vertex has even degree. We also showed that if more than
2 vertices has odd degree, there cannot be an Eulerian walk. (parts (a) and (c) of Theorem
7.3.1)
Now prove the remaining part (part (b) of Theorem 7.3.1): If G has exactly two vertices
v, w ∈ V with odd degree (and is connected), there is a Eulerian walk, and all Eulerian walks
have the odd-degree vertices v and w as endpoints.

Solution. Let G have exactly two vertices v and w with odd degree. Then adding an edge
between v and w yields a graph where every vertex has even degree, so by our above Theorem
we have a closed Eulerian walk, which passes through this new edge. Thus removing the edge
we have an Eulerian walk which starts at v and ends at w.
(Note that adding this edge could create a multigraph, but the Theorem holds for multi-
graphs so this is fine. Alternatively, if there was an edge between v and w already, we could
remove it and then find a closed Eulerian walk, and then add the edge back to make the walk
go from v to w).

Problem 9. (*) Recall that the complete bipartite graph Kn,m can be described by a vertex set
V = {a1 , . . . , an , b1 , . . . , bm } and an edge set E = {{ai , bj } : ∀i ∈ [n], j ∈ [m]}, where n, m ≥ 1.
Determine for which values of Kn,m there is an Eulerian walk, a closed Eulerian walk, a
Hamiltonian path, and a Hamiltonian cycle. For each of these four conditions, you must argue
why the walk/path/cycle in question exists for those values of n, m that you find, and why it
cannot exist for all other values of n, m.

Solution. For a closed Eulerian walk, every vertex must have even degree, which will be the case
when n and m are even. We can have a non-closed Eulerian walk when exactly two vertices have
odd degree, which is the case when n = 2 and m is odd (or vice-versa) (or the case n = m = 1,
which is trivially a path of length 1).
For a Hamiltonian cycle, we must pass each vertex exactly once, which is possible if and
only if n = m. In this case, one cycle is simply a1 , b1 , a2 , b2 . . . , an , bn , a1 . Because the cycle
must alternate between a and b vertices, it is clearly necessary to have n = m.
A Hamiltonian cycle also implies the existence of a Hamiltonian path, but there are also
additional cases where only a path exists, when |n − m| = 1. In this case, if without loss of
generality n = m + 1, then we have the path a1 , b1 , . . . , am , bm , am+1 . Likewise, because we
alternate between a and b vertices, there will be no such path if the difference |n − m| > 1.

Problem 10. (*) Let the Hamiltonian path and Hamiltonian cycle problems be the task of
deciding, giving an arbitrary graph G, if there exists a Hamiltonian path / cycle respectively
(so you take G as input and give a yes/no answer as output).
In class we saw that the Travelling Salesman problem was “at least as hard” as the Hamil-
tonian cycle problem. Now we will show that the Hamiltonian path and cycle problems are
“equally hard” as each other.
Assume you have an oracle that will instantly give you the answer to the question ‘does G
have a Hamiltonian path’ for any graph G you give it. Show how you can use this oracle to
quickly solve the Hamiltonian cycle problem.
Now assume you have an oracle that will answer the question ‘does G have a Hamiltonian
cycle’ for any graph G you give it. Show how you can use this oracle to quickly solve the
Hamiltonian path problem.

Solution. We will solve the second question first. Assume we have an oracle to solve HAM-
CYCLE, and we wish to solve the problem HAM-PATH, so are given a graph G and must

5
decide if it contains a Hamiltonian path. Now we create a new vertex u, and add an edge from
u to every other v ∈ V , to create G0 . We show that G0 has a Hamiltonian cycle if and only if
G has a Hamiltonian path:
If G has a Hamiltonian path, then let s and f be the endpoints of such a path. We can then
find a Hamiltonian cycle in G0 by following this path, then going from f to u and back to s.
Conversely, if G0 has a Hamiltonian cycle, let a and b be the two vertices that appeared before
and after u in the cycle. The rest of the cycle from b back to a gives a Hamiltonian path in G.
Thus we can ask the HAM-CYCLE oracle about G0 which gives the answer to our question,
so we have shown HAM-CYCLE is “at least as hard as” HAM-PATH.
The first question is similar, but the construction is slightly trickier. Assume we have an
oracle to solve HAM-PATH, and we wish to solve the problem HAM-CYCLE, so are given a
graph G and must decide if it contains a Hamiltonian cycle. Then we pick any vertex v ∈ V ,
and create a new vertex v 0 with the exact same edges as v. Then we create two new vertices,
s (connected only to v) and s0 (connected only to v 0 ). This creates a new graph G0 . Now we
show G0 has a Hamiltonian path if and only if G has a Hamiltonian cycle:
If G0 has a Hamiltonian path, its endpoints must be s and s0 , since they each have degree
1. Thus the middle section is a path from v to v 0 through every other vertex. Following the
last edge back to v instead of v 0 gives a cycle from v to itself just in G. Conversely, if G has a
Hamiltonian cycle, we can then find a Hamiltonian path in G0 by starting from s, going to v
and following the cycle but returning to v 0 instead of v, then going to s0 .
Thus we can ask the HAM-PATH oracle about G0 which gives the answer to our question,
so we have shown HAM-PATH is “at least as hard as” HAM-CYCLE.
This notion of “at least as hard as” is formalized by something called a polynomial-time
reduction (https://en.wikipedia.org/wiki/Polynomial-time_reduction), and arguments
of this form are how we know that these two problems (and many others) are something called
NP-Complete. This means they are in a class of problems known as NP (which intuitively
means you can quickly verify if the answer to the problem is yes, ie. you can quickly check
if somebody shows you a Hamiltonian path), but also that they are “at least as hard as”
every other problem in NP. There are many other examples of NP-Complete problems, see
https://en.wikipedia.org/wiki/List_of_NP-complete_problems. If you can come up with
an efficient algorithm for any of these, you will become very famous, but there’s strong reason
to suspect this is impossible.
(see https://www.geeksforgeeks.org/np-completeness-set-1/ for a quick introduction
to these ideas. The relevant course at Davis if you want to learn more would be ECS 120.)

You might also like