Homework Assignment #5

Give an implementation of graph class using adjacency matrix representation.

Hint: you can use int [ ] [ ] mat to store weights, and vertexMap as in the textbook

1. Use the table in Figure 14.4 on page 532 as the input. You can do this simply by calling

addEdge(String("D", String("C"), 10), addEdge(...), etc directly. So you need to implement addEdge(...) function.

 

2. Change the weight of edge AB from 12 to 13 and remove the edge (A, D, 87). Implement removeEdge(...) function.

You can implement changeWeight(...) function directly or do this by removeEdge and addEdge combination.

 

3. Print the the graph after the previous operations in the input format D C 10,... etc using breadth-first search (refer to page 546).

Again, your comment begins with //Name: , and your filename is YOURLOGIN_hwk5.java as before.