Data Structure Course Design - Project 2 - Campus Tour Guide Consultation (Experiment Preparation)

1. Problem description

Design a campus tour guide program to provide various information inquiry services for visiting guests.

2. Basic requirements

  1. Design the campus floor plan of your school, including no less than 10 scenic spots. The vertices in the figure represent the scenic spots in the school, and store information such as the name, code, and introduction of the scenic spots; the paths are represented by edges, and relevant information such as the length of the path is stored.
  2. Provide visitors with inquiries about information about any scenic spot in the map.
  3. Provide visitors with directions for any scenic spot in the map, that is, query a shortest simple path between any two scenic spots.

3. Problem analysis

1. Selection of data structure

Use an undirected graph as the data structure for this project, and an adjacency matrix as the storage structure for the undirected graph. Among them, the vertices of the graph are numbered according to 1-n to store the detailed information of n scenic spots on the campus (including scenic spot names, codes, brief introductions, etc.); the edges of the undirected graph represent the connectivity between two scenic spots, and The weight of an edge represents the path length between two attractions.

2. Definition of structure

1) Define an undirected graph node structure, each node in the graph represents a scenic spot on the campus, and the structure contains the detailed information of the scenic spot - the name of the scenic spot of type String, and the code name of the scenic spot of type int , the introduction of attractions of type String, etc.
2) Define an undirected graph structure, the private members include the array vertex[ ] for storing nodes, the array adj[ ] for storing adjacency matrix, and the number of nodes and edges.
3) Constructor and getter methods need to be written in the above two structures in order to create objects and read private members in the main method.

3. Function analysis

1) Provide visitors with inquiries about information about any scenic spot in the map. The user can query the detailed information of the corresponding scenic spot by inputting the scenic spot code or the scenic spot name.
2) Provide visitors with directions for any scenic spot in the picture, that is, to query a shortest simple path between any two scenic spots. The user inputs the codes of the two scenic spots and calls the corresponding function to output the distance between the two scenic spots. The shortest path and the shortest path length.

4. Logic Design

1. Module division

1) Main function module
2) Attraction information query module
3) Shortest path query module between two scenic spots

2. Abstract data structure ADT

ADT 校园导游咨询
	Data
	  校园中的各个景点及其详细信息
	  校园中景点两两之间的路径长度
	Operation
	  创建无向图
	    初始数据:景点和邻接矩阵
	    功能:由给定的初始数据确定一个带权值的无向网络图
      景点信息查询
        输入:景点代号或景点名称
        功能:查询该景点的详细信息
        输出:景点详细信息
      问路查询
        输入:两个景点代号
        功能:求出两个景点之间的最短路径
        输出:两个景点之间的最短简单路径
      查看景点列表
      	输入:无
      	功能:列出所有景点
      	输出:输出所有景点的代号即名称
      查看菜单
      	输入:无
      	功能:输出菜单界面
      	输出:输出用户选择菜单
      退出系统
      	输入:无
      	功能:退出该系统
      	输出:退出系统,欢迎下次使用!
endADT

3. Module call relationship diagram

insert image description here

5. Physical Design

1. Storage structure

1) Define a structure as the node type of the undirected graph, which is used to store information about a single scenic spot.
2) Define an array of the above structure type, and store all nodes in the array.
2) Use an integer two-dimensional array (matrix) to store the weight between every two nodes, which is used to represent the path length between two scenic spots.

2. Main function design

伪代码:
1.创建无向网络图,定义景点个数n
2.初始化n个景点的详细信息并存储在一个数组中和一个n*n的邻接矩阵
3.再提供用户界面供用户选择功能,用switch语句供用户选择
4.调用执行相应的用户选择模块

3. Sightseeing information query design

伪代码:
1.从键盘读取需要查询的景点的代号或景点名称
2.遍历存放所有结点的结点数组,寻找符合要求的结点
3.按照格式要求输出该景点的相关信息

4. Shortest path query design between two scenic spots

伪代码:
1.从键盘读取两个景点的代号
2.编写迪杰斯特拉算法,求图G中从i顶点到其他所有顶点的最短路径
  or编写弗洛伊德算法,求图G中每一对顶点之间的最短路径
3.输出步骤2中算法返回的最短路径
4.计算并输出最短路径的长度

5. Function algorithm framework

Function call diagram

6. Test data

1) Randomly select 11 scenic spots on the map of Jiangsu University of Science and Technology and number them as shown in the figure below:
Please add a picture description
2) The corresponding scenic spot names are as follows:

label Attraction name
1 North Gate of Jiangsu University of Science and Technology
2 Haiyun Lake
3 Arts and Sciences Building
4 Jingshi Building
5 library
6 Group No. 3
7 West dining room
8 West Playground
9 Sports Center
10 East Playground
11 East Canteen

3) Whether each scenic spot is connected or not and the length of the path between the connected scenic spots can be determined by yourself. The following is an undirected graph with rights that I made at will.
insert image description here

Guess you like

Origin blog.csdn.net/m0_59056822/article/details/124826898