CSD201_-_PE_-_SP_2025_3455.webp
Đ

CSD201_-_PE_-_SP_2025_3455.webp

☑Kizspy.me
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-5 (the vertex F) but
display 6 vertices with their degrees from the 2nd vertex to the 7th vertex only. Hint: copy
breadth(...) to breadth2(...) and modify the latter one. The array int deg[] already declared in the
class Graph. You should calculate d[i] = degree of the vertex i, i=0,1,..,n-1 and use the function
fvisitDeg(...) to display a vertice with degree to file. Content of the output file f1.txt must be:
FCAHBDEIG
C(3) A(3) H(2) B(3) D(3) E(2)
void f2()-Apply the Dijkstra's shortest path algorithm to find the shortest path from vertext 0 (A)
to vertex 6 (G). Write 3 lines to the file f2.txt: line 1 contains vertices in shortest path in which
the 3rd and the 4th vertices having labels. Line 2 contains the first 6 vertices selected into the set
S, line 3 contains the shortest distance. (Note that in the weighted matrix, the value 99 is
considered as infinity. When the vertex v is selected to the set S, its label = shortest distance from
starting vertex to it). Output in the file f2.txt must be the following:
AIC(5) E(8) DG
AICEBD
22
Zoom
+ 95%
Close
Chưa có bình luận nào.

Thông tin

Category
CSD201
Thêm bởi
Đức Long
Ngày thêm
Lượt xem
2,259
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom