2
Quesion 3: (2 marks)
In this question you should complete some methods in Graph.java file.
The class Graph is the implementation of a graph. The following methods should be completed:
void f1() - Perform depth-first traversal (to the file f1.txt) from the vertex i=2 (the vertex C) but display 4 vertices from the 3rd vertex to the 6th vertex only. Hint: copy depth(...) to depth2(...)and modify the latter one. Content of the output file f1.txt must be:
CABEHIDGF
BEHI
void f2() - Apply the Dijkstra's shortest path algorithm to find (1) the shortest path from vertext 2 (C) to vertex 5 (F), then (2) from vertex 0 (A) to vertex 6 (G). Write 3 lines to the file f2.txt: line 1 contains the last 4 vertices selected into the set S with their labels in (2), line 2 contains vertices in shortest path (2), line 3 contains vertices in shortest path (1). (Note that in the weighted matrix,the value 99 is considered as infinity). Output in the file f2.txt must be the following:
E:15 D:19 F:24 G:29
ABCEDG
CEDF
90%
Zoom
Close