## Tutorial Topic

Graph Implementation and Graph Traversal

### Tutorial Questions

1. The bridges of Königsberg

In the 18th Century, the Prussian town of Königsberg (now Kaliningrad) was famous for the seven bridges connecting its two central islands with the banks of the River Pregel, as shown in the diagram. Can you draw a path which crosses each bridge exactly once? If not, explain why.

2. Data Structures for Graphs (G&T Chap 13)

R-12.8 Would you use the adjacency list structure or the adjacency matrix structure in each of the following cases? Justify your choice.

a) The graph has 10,000 vertices and 20,000 edges, and it is important to use as little space as possible.
b) The graph has 10,000 vertices and 20,000,000 edges, and it is important to use as little space as possible.
c) You need to answer the query areAdjacent() as fast as possible, no matter how much space you use.

3. Graph Traversal (G&T Chap 13)

Let G be the graph whose vertices are the integers from 1 to 9 , and let the adjacent vertices of each vertex be as follows:

```1:  2,3
2:  1,3
3:  1,2,6,9
4:  5,6
5:  4,6
6:  3,4,5,9
7:  8,9
8:  7,9
9:  3,6,7,8
```
a) Draw G
b) Draw the spanning tree created by a DFS traversal of G
c) Draw the spanning tree created by a BFS traversal of G