Sei sulla pagina 1di 16

Name: NIM: Class:

Solution to Assignment 3: Graphs


Discrete Mathematics - A (MSH1A3)
Second Term 2016-2017
Instructions:

1. This assignment is due Thursday April 20 at 5:00 p.m.. Please submit your work at School of
Computing academic roster (roster akademik Fakultas Informatika), room A203A (building A room
A203A). Do not forget to write your identity on the space provided. You may submit this assignment as
of Monday April 17 at 8:00 a.m..

2. In order to prevent any academic misconduct, you also need to submit a readable scan or photograph of
this assignment to the provided submission slot in IDEA. Please contact your class instructor for more
detailed information. The due date of this online submission is the same as the hardcopy. Please make
sure that your file size do not exceed the maximum file size allowed.

3. To save paper, you may print and reproduce this assignment double-sided.

4. Your answers should be handwritten. You may use: HB or 2B pencil, or pen with blue or black ink.

5. All problems in this assignment are adapted from the textbooks. The problems are written in English.
If you are a student in a regular class, you may answer the problems in Bahasa. However, if you are a
student in international class, your answers must be written in English otherwise your assignment will
not be graded. You may ask your class instructor or teaching assistant for helping you understanding the
problem, but you should not ask them to give the solution of any problem.

6. Write your solutions on the space provided. If you need more space, you may use additional A4 papers
and attach them to your assignment.

7. Be neat and write legibly. You will be graded not only on the correctness of your answers, but also on
the clarity with which you express them.

8. This assignment consists of 9 problems and each problem is worth differently.

9. Please retain yourself from copying answers from elsewhere without understanding the steps. This
assignment is an individual evaluation.

10. Important: late submission without reasonable explanation will not be graded.

page 1 of 16
Problem 1 (10 points) Suppose G = (V; E) is a simple undirected graph illustrated in Figure 1.

Figure 1: Graph G.

(a). [3 points] Construct AG , i.e., the adjacency matrix of G.

(b). [3 points] Construct the adjacency list of G.

(c). [4 points] How many different paths of length four from a to d? (Hint: calculate A4G .)

S OLUTION :
2 3
0 1 1 1
6 7
6 1 0 0 1 7
(a). We have AG = 6
6 1
7.
4 0 0 1 7
5
1 1 1 0

(b). The adjacency list of G is


Vertex Adjacent vertices
a b, c, d
b a, d
c a, d
d a, b, c

(c). We have
2 32 3 2 3
0 1 1 1 0 1 1 1 3 1 1 2
6 76 7 6 7
6 1 0 0 1 76 1 0 0 1 7 6 1 2 2 1 7
A2G =66 7 6 7=6 7 and
76 7 6 1 7
4 1 0 0 1 54 1 0 0 1 5 4 1 2 2 5
1 1 1 0 1 1 1 0 2 1 1 3
2 32 3 2 3
3 1 1 2 3 1 1 2 15 9 9 14
6 76 7 6 7
6 1 2 2 1 7 6 1 2 2 1 7 6 10 9 7
A4G = 6 76 7 6 9 10 7.
6 1 2 2 1 7 6 1 2 2 1 7 = 6 9 10 10 9 7
4 54 5 4 5
2 1 1 3 2 1 1 3 14 9 9 15
Therefore, there are 14 different paths of length three from a to d.

page 2 of 16
Name: NIM: Class:

Problem 2 (10 points) A simple undirected graph is an undirected graph with no multiple parallel edges
or loops. A k-regular graph is a simple graph whose every vertex has degree k:

(a). [5 points] Is there any 5-regular graph with seven vertices? If so, draw such graph; otherwise, explain
your answer.

(b). [5 points] Is there a k-regular graph with eight vertices and twelve edges? If so, determine the value
of k; otherwise, explain your answer.

S OLUTION :
P P
(a). No. By the handshaking theorem, v2V deg (v) = v2V 5 = 5 (7) = 35 = 2 jEj, so
35
jEj = 2 = 17 12 62 Z, which is impossible.

(b). Yes. Suppose G = (V; E) is a k-regular graph with eight vertices and twelve edges, then by
the handshaking theorem
X
deg (v) = 2 jEj
v2V
X
k = 2 12
v2V

8k = 24
k = 3.

Hence, the value of k is 3. To verify, observe that a 3-regular graph with eight vertices has
1
P 1
2 v2V 3 = 2 (3 8) = 12 edges.

page 3 of 16
Problem 3 (10 points) A city is divided into nine regions labelled as a, b, . . . , i. These regions and the
roads connecting them is illustrated in Figure 2.

Figure 2: Graph G.

The vertices depict the regions and the edges are the roads connecting them.

(a). [5 points] A salesperson plans to visit all regions in the city. To gain efficiency, he intends to visit
each of the nine regions once and return to his starting point. Determine whether this plan can be
done. If so, give an example of the corresponding Hamilton circuit; otherwise, prove that no such
circuit exists.

(b). [5 points] A group of construction workers is ordered to pave the roads connecting the regions. To
gain efficiency, the group intends to pave the roads continuously and traverse each of the roads once.
Determine whether this plan can be done. If so, give an example of the corresponding Euler circuit/
path; otherwise, prove that no such circuit/ path exists.

S OLUTION :

(a). The plan is possible because the graph G has a Hamilton circuit. One example of such
circuit is
he; d; a; b; c; f; i; h; g; ei .

(b). The plan is impossible because the graph G does not have an Euler path, since it contains
more than two vertices of odd degree. To be precise, all vertices but e has degree 3.

page 4 of 16
Name: NIM: Class:

Problem 4 (10 points) Determine whether the following pair of graphs is isomorphic or not. Exhibit an
isomorphism or provide rigorous argument that none exist. If the graphs are isomorphic, show that we can
rearrange the vertices of the graphs so that their adjacency matrices are identical.

(a). [5 points] Graph G (left) and graph H (right) in Figure 3.

Figure 3: Graph G (left) and H (right).

(b). [5 points] Graph G (left) and graph H (right) in Figure 4.

Figure 4: Graph G (left) and H (right).

S OLUTION :

(a). We have G = H with the isomorphism f : VG ! VH such that


f (u1 ) = v6 , f (u2 ) = v2 , f (u3 ) = v3 , f (u4 ) = v5 , f (u5 ) = v4 , and f (u6 ) = v1 .

Observe that the adjacency matrix for G with vertices label u1 ; u2 ; : : : ; u6 is


2 3
0 1 0 1 0 1
6 7
6 1 0 1 0 0 1 7
6 7
6 0 1 0 1 1 0 7
6 7
AG = 6 7,
6 1 0 1 0 1 0 7
6 7
6 0 0 1 1 0 1 7
4 5
1 1 0 0 1 0

page 5 of 16
and the adjacency matrix for H with vertices label v6 ; v2 ; v3 ; v5 ; v4 ; v1 is
2 3
0 1 0 1 0 1
6 7
6 1 0 1 0 0 1 7
6 7
6 0 1 0 1 1 0 7
6 7
AH =6 7.
6 1 0 1 0 1 0 7
6 7
6 0 0 1 1 0 1 7
4 5
1 1 0 0 1 0

The graph H can be redrawn as follows:

= because the graph G is not connected and it has two connected components
(b). We have G=H
(G is not connected because there is no path from any vertex in fa; c; eg to any vertex in
fb; d; f g), whereas the graph H is a connected graph.

page 6 of 16
Name: NIM: Class:

Problem 5 (10 points) Suppose F and G are two graphs in Figure 5.

Figure 5: Graph F (left) and G (right).

(a). [5 points] Determine whether graph F and G are isomorphic. Exhibit an isomorphism or provide
rigorous argument that none exist. If the graphs are isomorphic, show that we can rearrange the
vertices of the graphs so that their adjacency matrices are identical.

(b). [5 points] Determine whether graph H in Figure 6 can be drawn without any edges crossing (i.e.,
whether H is planar or not). If so, draw it so that no edges cross; if not, explain your answer
mathematically.

Figure 6: Graph H.

S OLUTION :

(a). We have F = G with the isomorphism f : VF ! VG such that


f (a) = u1 , f (b) = u3 , f (c) = u5 , f (d) = u2 , f (e) = u4 , and f (f) = u6 .
Observe that the adjacency matrix for F with vertices label a; b; : : : ; f is
2 3
0 0 0 1 1 1
6 7
6 0 0 0 1 1 1 7
6 7
6 0 0 0 1 1 1 7
6 7
AF = 6 7,
6 1 1 1 0 0 0 7
6 7
6 1 1 1 0 0 0 7
4 5
1 1 1 0 0 0

page 7 of 16
and the adjacency matrix for G with vertices label u1 ; u3 ; u5 ; u2 ; u4 ; u6 is
2 3
0 0 0 1 1 1
6 7
6 0 0 0 1 1 1 7
6 7
6 0 0 0 1 1 1 7
6 7
AG = 6 7.
6 1 1 1 0 0 0 7
6 7
6 1 1 1 0 0 0 7
4 5
1 1 1 0 0 0

The graph G can be redrawn as follows:

(b). Since F = G, then G is not planar. Observe that by removing following edges from H

fu7 ; u8 g , fu8 ; u9 g , fu9 ; u10 g , and fu10 ; u7 g ,

we obtain the following subgraph H 0 of H

The subgraph H 0 is homeomorphic to G because it can be obtained from the following


sequences of elementary subdivisions :

(i) deleting fu1 ; u2 g, adding the vertex u7 and the edges fu1 ; u7 g and fu7 ; u2 g,
(ii) deleting fu3 ; u4 g, adding the vertex u8 and the edges fu3 ; u8 g and fu8 ; u4 g,
(iii) deleting fu4 ; u5 g, adding the vertex u9 and the edges fu4 ; u9 g and fu9 ; u5 g,
(iv) deleting fu6 ; u1 g, adding the vertex u10 and the edges fu6 ; u10 g and fu10 ; u1 g.

Therefore, since H contains a subgraph that is homeomorphic to a non-planar graph, then


H is also a non-planar graph.

page 8 of 16
Name: NIM: Class:

Problem 6 (10 points) The graph K5 is a simple undirected graph with five vertices in which every pair of
different vertices is connected by an edge. This graph is illustrated in Figure 7.

Figure 7: Graph K5 .

(a). [5 points] Determine the number of different spanning subgraph of K5 (i.e., the subgraph of K5
which contains all the five vertices).

(b). [5 points] Draw three non-isomorphic spanning trees of K5 . Explain why these trees are not isomor-
phic.

S OLUTION :

(a). Suppose K5 = (VK5 ; EK5 ) and G = (V; E) is a spanning subgraph of K5 . Then V = K5 =


fa; b; c; d; eg and E EK5 . Thus, the number of different spanning subgraphs of K5 is equal
to the number of different subsets of E , i.e., 2jEK5 j = 210 = 1024.
K5

Alternatively, suppose G = K5 = (VK5 ; EK5 ) and G = (V; E) is a spanning subgraph of K5 .


Then V = K5 = fa; b; c; d; eg and the elements of E can be taken from the elements of EK5 .
Since there are 10 edges in K5 and any edge in the spanning subgraphs of K5 has two
possibilities, i.e., either it is included in E or not, then there are

2| 2{z 2} = 210 = 1024


10 terms

spanning subgraphs of K5 .

(b). Observe the following graphs:

Tree T1 . Tree T2 . Tree T3 .

page 9 of 16
These graphs are trees because each of them is connected and contains no simple circuit.
All of them are not isomorphic one another because:

= 2 because T1 does not have a vertex of degree 3,


(i) T1 =T
= 3 because T1 does not have a vertex of degree 4,
(ii) T1 =T
= 3 because T2 does not have a vertex of degree 4.
(iii) T2 =T

page 10 of 16
Name: NIM: Class:

Problem 7 (15 points) Alice, Bob, Carlos, David, Emma, and Fiona are classmates. One day, their teacher
gave them a group programming project. The group must contain at least two people. However, there are
some conditions that must be considered:
1. Alice cannot be grouped with Emma and Fiona;
2. Bob cannot be grouped with Carlos and David;
3. Carlos cannot be grouped with Bob, Emma, and Fiona;
4. David cannot be grouped with Bob and Emma;
5. Emma cannot be grouped with Alice, Carlos, and David;
6. Fiona cannot be grouped with Alice and Carlos.
Your task is to group these six students using as few number of groups as possible.

(a). [5 points] Draw a graph G = (V; E) that represents the non-possible grouping with V = fa; b; : : : ; f g
where a represent Alice, b represent Bob, and so on. Two vertices are adjacent if and only if the stu-
dents cannot be grouped together.

(b). [5 points] Use Welsh-Powell algorithm to determine the minimum number of color required to color
the vertices in G.

(c). [5 points] Is it possible to group the student according to the above-mentioned conditions? If so,
provide an example of the grouping; otherwise, explain why the grouping is impossible.

S OLUTION :

(a). We have the following graph:

(b). We have:
vertex c e a b d f
degree 3 3 2 2 2 2
color red yellow red yellow red yellow

The colored graph is depicted as follows:

page 11 of 16
(c). Yes, it is possible. Using the graph coloring scheme, one example of the grouping is as
follows:

group one: Alice, Carlos, David


group two: Bob, Emma, Fiona.

page 12 of 16
Name: NIM: Class:

Problem 8 (10 points) A pipeline network is to be built that will link six cities labelled as a, b, . . . , and
f . The blueprint of the network is illustrated in Figure 8. The vertices represent the cities and the edges
are the pipelines connecting them. The cost (in million dollars) of constructing each potential link depends
on the distance and terrain and is shown as edges label. For example, the cost of building the pipeline that
connects city a and b is $10 million.

Figure 8: Pipeline networks graph.

One day, a financial crisis hits the country and the blueprint needs to be revised. The new network needs
to connect all the cities and yet minimize the total construction cost. Your task is to find such configuration
and calculate its costs.

(a). [5 points] Use Prims algorithm to find the configuration. Describe the iterations, calculate the total
cost, and draw the resulting network.

(b). [5 points] Use Kruskals algorithm to find the configuration. Describe the iterations, calculate the
total cost, and draw the resulting network.

S OLUTION : We need to find the minimum spanning tree of the graph. Since jV j = 6, then any
spanning tree consists of five edges.

(a). By using Prims algorithm, we have

choice no. 1 2 3 4 5
edge fc; eg fe; dg fe; bg fa; bg fa; f g .
length 5 11 13 10 12

The total cost is 5 + 11 + 13 + 10 + 12 = $51 million, and the resulting network is depicted as
follows:

page 13 of 16
(b). By using Kruskals algorithm, we have

choice no. 1 2 3 4 5
edge fc; eg fa; bg fe; dg fc; f g fb; eg .
length 5 10 11 12 13

The total cost is 5 + 11 + 13 + 10 + 12 = $51 million, and the resulting network is identical to
the tree in point (a).

page 14 of 16
Name: NIM: Class:

Problem 9 (15 points) Suppose we have graph G as in Figure 9.

Figure 9: Graph G.

Use Dijkstras algorithm to find the shortest path (and its length) between a and z. Elaborate each of
the iterations in the algorithm.

S OLUTION : We have following iterations

(a). Iteration 0 (initialization)

(i) S0 = ;
(ii) L0 (a) = 0
(iii) L0 (b) = L0 (c) = L0 (d) = L0 (e) = L0 (z) = 1
(iv) z 2 S0 , iteration is continued.

(b). Iteration 1

(i) u := a, because a 62 S0 and L0 (a) is minimal


(ii) S1 = S0 [ fug = fag.
(iii) L1 (b) = min fL0 (b) ; L0 (a) + w (a; b)g = min f1; 0 + 2g = 2.
The shortest path from a to b is ha; bi.
L1 (c) = min fL0 (c) ; L0 (a) + w (a; c)g = min f1; 0 + 3g = 3.
The shortest path from a to c is ha; ci.
(iv) L1 (d) = L1 (e) = L1 (z) = 1 because d, e, and z are not adjacent to a.
(v) z 62 S1 , iteration is continued.

(c). Iteration 2

(i) u := b, because b 62 S1 and L1 (b) is minimal


(ii) S2 = S1 [ fug = fa; bg.
(iii) L2 (c) = min fL1 (c) ; L1 (b) + w (b; c)g = min f3; 2 + 1g = 3.
The shortest path from a to c is still ha; ci.
L2 (d) = min fL1 (d) ; L1 (b) + w (b; d)g = min f1; 2 + 5g = 7.
The shortest path from a to d is ha; b; di.
L2 (e) = min fL1 (e) ; L1 (b) + w (b; e)g = min f1; 2 + 2g = 4.
The shortest path from a to e is ha; b; ei.
(iv) L2 (z) = min fL1 (z) ; L1 (b) + w (b; z)g = min f1; 2 + 1g = 1.

page 15 of 16
(v) z 62 S2 , iteration is continued.

(d). Iteration 3

(i) u := c, because c 62 S2 and L2 (c) is minimal


(ii) S3 = S2 [ fug = fa; b; cg.
(iii) L3 (d) = min fL2 (d) ; L2 (c) + w (c; d)g = min f7; 3 + 1g = 7.
The shortest path from a to d is still ha; b; di.
L3 (e) = min fL2 (e) ; L2 (c) + w (c; e)g = min f4; 3 + 5g = 4.
The shortest path from a to e is still ha; b; ei.
(iv) L3 (z) = min fL2 (z) ; L2 (c) + w (c; z)g = min f1; 3 + 1g = 1.
(v) z 62 S3 , iteration is continued.

(e). Iteration 4

(i) u := e, because e 62 S3 and L3 (e) is minimal


(ii) S4 = S3 [ fug = fa; b; c; eg.
(iii) L4 (d) = min fL3 (d) ; L3 (e) + w (e; d)g = min f7; 4 + 1g = 5.
The shortest path from a to d is ha; b; e; di.
L4 (z) = min fL3 (z) ; L3 (e) + w (e; z)g = min f1; 4 + 4g = 8.
The shortest path from a to z is ha; b; e; zi.
(iv) z 62 S4 , iteration is continued.

(f). Iteration 5

(i) u := d, because d 62 S4 and L4 (d) is minimal


(ii) S5 = S4 [ fug = fa; b; c; e; dg.
(iii) L5 (z) = min fL4 (z) ; L4 (d) + w (d; z)g = min f8; 5 + 2g = 7.
The shortest path from a to z is ha; b; e; d; zi.
(iv) z 62 S5 , iteration is continued.

(g). Iteration 6

(i) u := z, because z 62 S5 and L5 (z) is minimal


(ii) S6 = S5 [ fug = fa; b; c; e; d; zg.
(iii) No vertex is labelled 1.
(iv) z 2 S6 , iteration is completed.

Therefore, the shortest path from a to z is ha; b; e; d; zi of length 7.

page 16 of 16

Potrebbero piacerti anche