CSD201_-_PE_-_SU_2024_-_Block_5_2621.webp
Minh Phúc2

CSD201_-_PE_-_SU_2024_-_Block_5_2621.webp

(C,5,2) (D,2,1) (G,4,6) (E,6,5) (F,1,3) (H,3,4)
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=0 (the vertex A) but display 4 vertices from the 2nd vertex to the 5th vertex only. Hint: copy depth(...) to depth2(...)and modify the latter one. Content of the output file f1.txt must be:
ABEHICDGF
BEHI
void f2() - Apply the Dijkstra's shortest path algorithm to find (1) the shortest path from vertext 1 (B) 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 vertices in shortest path (1), line 2 contains vertices in shortest path (2), line 3 contains the last 3 vertices selected into the set S with their labels in (2). (Note that in the weighted matrix,the value 99 is considered as infinity). Output in the file f2.txt must be the following:
BCEDF
ABCEDG
D-19 F-24 G-29
Zoom

+ 78%
Close
Chưa có bình luận nào.

Thông tin

Category
CSD201
Thêm bởi
Minh Phúc2
Ngày thêm
Lượt xem
3,885
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
CSD201_-_PE_-_SU_2024_-_Block_5_2621.webp
File size
70.8 KB
Dimensions
1920px x 803px

Share this media

Back
Bên trên Bottom