CSCE 235
Homework
Assignment 10 -- Solution
Assigned: April 8, 2009
Due: 12:30 p.m. April 17,
2009
(Homework 5 minutes late will not be
accepted)
Graph Elements
1. (5 points) How many vertices and how many edges does the following graph contain? What is the degree sequence of this graph?

Solution
The number of vertices is 6. The number of edges is 13. The degree sequence is 5, 5, 5, 4, 4 3.
![]()
Subgraphs,
Complete Graphs, Bipartite Graphs, Isomorphism
2. (20
points) For each
pair of graphs shown, discover whether or not the graph on the left is a subgraph of the one on the right. If it is not, explain why not. If it is, label the vertices of the subgraph, then use the same symbols to label the
corresponding vertices of the graph on the right.
(a)
(b) 
(c)
(d) 
Solution
(a) No. The graph on the left is not a subgraph of the one on the right.
(b) Yes, the graph on the left is a subgraph of the graph on the right. Here are the labels:

(c) Yes, the graph on the left is a subgraph of the graph on the right. Here are the labels:

(d) Yes, the graph on the left is a subgraph of the graph on the right. Here are the labels:

![]()
3. (20 points) For each graph shown, determine whether or not the graph is bipartite. In each case, give the bipartition sets or explain why the graph is not bipartite.
(a)
(b) 
(c)
(d) ![]()
Solution
(a) Yes. To find the top and bottom vertices, we can color the vertices of an edge with different colors (filled or blank in this example):

Since it is possible to color all the vertices for all edges without any conflicts, we can say that the graph is bipartite. Now, all the filled vertices form one cluster (A, C, E, and F), and all the blank vertices form another cluster (B, D, and G) and these two become the top and bottom bipartition sets of vertices. The re-drawn bipartition graph is:

(b) Yes. To find the top and bottom vertices, we can color the vertices of an edge with different colors (filled or blank in this example):

Since it is possible to color all the vertices for all edges without any conflicts, we can say that the graph is bipartite. Now, all the filled vertices form one cluster (A, D, F, and H), and all the blank vertices form another cluster (B, C, E, and G) and these two become the top and bottom bipartition sets of vertices. The re-drawn bipartition graph is:

(c) No. The graph has at least one triangle. That means the graph cannot be bipartite.
(d) Yes. To find the top and bottom vertices, we can color the vertices of an edge with different colors (filled or blank in this example):

Since it is possible to color all the vertices for all edges without any conflicts, we can say that the graph is bipartite. Now, all the filled vertices form one cluster (A, D, F, and H), and all the blank vertices form another cluster (B, C, E, and G) and these two become the top and bottom bipartition sets of vertices. The re-drawn bipartition graph is:

![]()
4. (20 points) For each pair of graphs shown, if the graphs are not isomorphic, explain why not; if the graphs are isomorphic, exhibit an isomorphism from one to the other and relabel the graph on the right so as to show this isomorphism.
(a)
(b) 
(c) 
(d) 
Solution
(a) The two graphs are not isomorphic. Each vertex of the graph on the left has a degree of 3. But there are vertices in the graph on the right with degrees higher than 3 (e.g., w).
(b) Suppose the graph on the left is G1, and the graph on the right is G2. In each of the graphs, there is only one vertex with a degree of 3: B in G1 and r in G2. So, a 1-to-1 mapping would have to map B to r. However, B is adjacent to a vertex—i.e., A, that has a degree of 1, while r is NOT adjacent to any vertex with a degree of 1. Therefore, the mapping from B to r would not be valid. If so, then there is no way we can map B in G1 to any vertex in G2. Therefore, the two graphs are NOT isomorphic.
(c) Yes, the two graphs are isomorphic. The mappings of nodes are: a à x, b à y, c à z, d à w, e à u, f à v, h à t, and g à s.
(d) Yes, the two graphs are isomorphic. The mappings of nodes are: B à t, C à u, D à v, Eà q, F à s, H à r, and G à p.
Euler and
5. (20 points) Which of the following has a



(a) (b) (c) (d) (e)
(a) The graph above has an Euler circuit,
but not a
(b) The graph above does not have an Euler
circuit. There is at least one vertex
with an odd degree. The graph above has
a
(c) The
graph above does not have an Euler circuit.
It is not connected. The graph
does not have a
(d) The
graph above does not have an Euler circuit.
There is at least one vertex with an odd degree. The graph has a
(e) The graph above does not have an Euler
circuit. There is at least one vertex
with an odd degree. The graph has a
Programming
6. (40 points) Toolbox. Build a program that determines whether a graph is bipartite. (Hint: Use the filled-empty node coloring to implement this.) Here below is a sample of an input file
2 a b
1
a b
4 m a t h
5
m a
m h
a t
h t
a h
8 a b c d e f g h
10
a b
a h
h c
g d
c f
g f
c d
d e
f e
b g
…
…
…
END
In the above, the first graph has 2 vertices: a, and b. The graph has 1 edge: (a,b). The second graph has 4 vertices: m, a, t, and h. The graph has 5 edges: (m,a), (m,h), (a,t), (h,t), and (a,h). The third graph has 6 vertices: a, b, c, d, e, and f. It has 10 edges: (a,b), (a,h), (h,c), (g,d), (c,f), (g,f), (c,d), (d,e), (f,e), and (b,g). Your output should be:
graph 1
is bipartite
graph 2
is not bipartite
graph 3
is bipartite
…
EXIT
Important:
(a) Your program will read in an
input file and output the outcome to the screen.
(b) Make sure that you have a
README file to describe how to run your program.
(c) If you have more than 1
program file, have a README file to describe how to compile your program.
Bonus (10 points):
In addition to generating the above output, generate
the resulting bipartition if a graph is bipartite. So the output now becomes:
graph 1
is bipartite: {a} {b}
graph 2
is not bipartite
graph 3
is bipartite: {a, c, g, e} {b, h, d, f}
…
EXIT
The order of the vertices in each set is not important.