第 1 页 共 9 页
1 . Write a BFS-based shortest path program which
includes the following functions.
1) A function readGraph( ), which reads graph data from a file,
graph.txt, to a graph data structure (either adjacency matrix or
adjacency linked list). Each row of the file represents a link
connecting the node on the first and second columns. For
example, the
following 4 lines are the data for Graph 1.
1 2
1 3
1 4
2 4
Note: Since this is an undirected graph, “1 2” implies that “2 1”
is also a link. If you use an adjacency matrix to store the graph,
it will be a symmetric one. You can assume that the maximum
number of vertices in the graph is 50.
第 1 页 共 9 页