# Arithmetic Q

Topics: Graph theory, Kruskal's algorithm, Adjacency list Pages: 4 (421 words) Published: April 17, 2013
Question 1:

Consider the following graph G.

[pic]

1. Give the adjacency matrix and adjacency list of the graph G. (5 marks)

[pic]

|a |
| b |
|c |
| d |
|e |
|f |

b d
a c e
b e f
a e
b c d f
c e

2. Give the incidence matrix and incidence list of the graph G. (5 marks)

[pic]
incidence matrix
[pic]

incidence list

|1 |
| 2 |
|3 |
| 4 |
|5 |
|6 |

a b
a d
b c
b e
c e
c e
|7 |
| 8 |

d e
e f

Question 2: Consider the graph

I. Starting at the vertex a and resolving ties by the vertex alphabetical order traverse the graph by breadth-first-search (BFS) and construct the corresponding BFS tree. (5 marks) [pic]

The order is : a b e g f c d h

II. Starting at the vertex a and resolving ties by the vertex alphabetical order traverse the graph by depth-first-search (DFS) and construct the corresponding BFS tree. (5 marks) [pic]

The order is : a b f e g c d h

Question 3:

Consider the following graph G. The label of an edge is the cost of the edge.

1. Using Prim's algorithm, draw a minimum spanning tree (MST) of the graph Also write down the change of the priority queue step by step and the order in which the vertices are selected. Is the MST drawn unique? (i.e., is it the one and only MST for the graph?) [7 marks]

Not unique

[pic]

2. Using Kruskal’s algorithm, draw a minimum spanning tree (MST) of the graph G. Write down the order in which the edges are selected. Is the MST drawn...