CSD201_-_PESP_2024_s_1_1500.webp
Izumi99

CSD201_-_PESP_2024_s_1_1500.webp

  • Media owner Izumi99
  • Ngày thêm
2
(C,8,2) (D,6,1) (F,2,106) (1,1,7) (K,-1,5) (J,3,9) (L,5,10) (M,4,6) (G,7,3) (Ε,9,4) (H,10,8)
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 breadth-first traversal (to the file f1.txt) from the vertex i=3 (the vertex D) but display 5 vertices from the 4th vertex to the 8th vertex only. Hint: copy breadth(...) to breadth2(...)and modify the latter one. Content of the output file f1.txt must be:
DAGBCEHIF
BCEHI
. 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 the last 3 vertices selected into the set S in (2), line 3 contains vertices with their labels in shortest path (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
DFG
A|0 B 10 C12 E 15 D 19 G|29
+ 100%
Zoom

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

Thông tin

Category
CSD201
Thêm bởi
Izumi99
Ngày thêm
Lượt xem
973
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
CSD201_-_PESP_2024_s_1_1500.webp
File size
213.4 KB
Dimensions
1920px x 863px

Share this media

Back
Bên trên Bottom