CSCE 235

Homework Assignment 10 (Programming)

Assigned:  April 11, 2008

Due: 12:30 a.m. April 21, 2008

(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?

 

 

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) 

 

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) 

 

 

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) 

 

Euler and Hamilton Circuits

 

5.   (20 points)  Which of the following has a Hamilton circuit?  Which of the following has an Euler circuit?  Explain briefly.

 

                          

                  (a)                    (b)                                (c)                       (d)                   (e)

 

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.