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

Question on graphs

November 21, 2021

Consider the graph on the left of Figure 1 below.


3
A B A B
E 3
E
2 1 7

F 3 F 2

D C D C
4

Figure 1: On the left is the graph for the questions 4(a) – (d). On the right
is the directed graph for the questions 4(e) – (f).

1. Is the graph on the left of Figure 1 a tree? Justify your answer.

Answer The graph is not a tree because it contains cycles: for exam-
ple, A − B − C − D − A.

2. Compute the degree of every vertex in the graph on the left of Figure 1.

Answer The degrees of A, B, C, D, E, F are 2,3,3,3,2,3.

3. Explain why the graph has no Eulerian paths.

Answer Since there are more than 2 vertices of odd degree.

1
4. Given an example of two edges that can be removed from the graph
such that the resulting graph has an Eulerian path and every Eulerian
path in the resulting graph starts and terminates in the same vertex?
Justify your answer.

Answer Only such example is DF and BC. After removing DF and


BC, the resulting graph is the cycle A − B − E − F − C − D − A.
More importantly, the resulting graph is connected and every vertex
has even degree.

5. Is the directed graph on the right of Figure 1 a rooted tree? Justify


your answer.

Answer The underlying undirected graph is not a tree (contains cycle


A − B − C), so the directed graph cannot be a rooted tree.

6. Using Dijkstra’s algorithm, find a shortest directed path from A to C


in the directed graph on the right of Figure 1.

Answer The application of Dijkstra’s algorithm could be illustrated


as follows:
Step Costs Visited Vertices
0 A
1 (A–D, 2), (A–B,3) A, D
2 (A–D, 2) | (A–B,3), (A–F, 5) A, D, B
3 (A–D, 2), (A–B,3) | (A–F, 5), (A–E, 6), (A–C, 10) A, D, B, F
4 (A–D, 2), (A–B,3), (A–F, 5) | (A–E, 6), (A–C, 7) A, D, B, F, E
5 (A–D, 2), (A–B,3), (A–F, 5), (A–E, 6) | (A–C, 7) A, D, B, F, E, C
The length of the shortest path is 7, the shortest path is A−D−F −C.

You might also like