(C,8,2) (D,6,1) (Ε,9,4) (F,2,-1) (G,7,3) (H,10,8) (1,1,7) (L,5,10) (Κ,-1,5) (1,3,9) (Μ,4,6)
Question 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=3 (the vertex D) but display 5 vertices from the 3rd vertex to the 7th vertex only. Hint: copy depth(...) to depth2(...)and modify the latter one. Content of the output file f1.txt must be:DABEHICGF
BEHIC
void f2() - Apply the Dijkstra's shortest path algorithm to find (1) the shortest path from vertext 0 (A) to vertex 6 (G), then (2) from vertex 1 (B) to vertex 5 (F). Write 3 lines to the file f2.txt: line 1 contains the last 3 vertices selected into the set S with their labels in (1), line 2 contains the 1st, 3rd and last vertices in shortest path (1), line 3 contains vertices in shortest path (2). (Notethat in the weighted matrix, the value 99 is considered as infinity). Output in the file f2.txt must be the following:
D 19 F 24 G 29
ACG
BCED F
+ 100%
Zoom
Close