Homework 8 (due Mo 11/13)
I provide you with a file. Each line represents an undirected edge together with a weight. As you read in this data, you may want to represent this graph as an adjacency matrix or as an adjacency list.
- Write a program that does a depth-first search. Run it starting from vertices 1, 3 and 10. Write out the number of each vertex as you visit, as well as the spanning tree. What is the cost (sum of weights) of this tree?
- Same as above, but do a breadth-first search.
- Find the minimal spanning tree. What is its cost?