Traffic Advisory System (Data Structure Course Design)

foreword

        This semester, I made a data structure course design, and my topic was the traffic consulting system. The hard requirement is to form a team to complete, but in fact the whole system is basically written by me. For the sake of teammates, I gave him the part of the algorithm.

        Then, because the course design template sent by the teacher is relatively formal, I wrote a lot of nonsense in the course design report (topic analysis, data structure design, algorithm analysis), so I cannot directly copy the course design report to everyone. I will copy the part displayed by the system separately, and the detailed explanation is in the source code.

Finally, in fact, for the interface part, I basically directly used the template when I wrote the C language course design, just made some optimizations.

Topics

Traffic Advisory System Design (Shortest Path Problem)

[Problem description] Today, when the transportation network is very developed, and the means of transportation and transportation methods are constantly updated, people not only care about saving transportation costs , but also are interested in issues such as mileage and required time when traveling on business, traveling or doing other trips. For such a problem that people care about, a graph structure can be used to represent the traffic network system, and a traffic consulting system can be established by using a computer. The vertices in the graph represent cities, and the edges represent the traffic relationship between cities . This transportation system can answer all kinds of questions from travelers. For example, a passenger wants to travel from city A to city B, and he hopes to choose a route with the least number of transit times . Assuming that each station in the graph needs to change trains, then this problem is reflected on the graph to find a path from vertex A to B that contains the least number of edges . We only need to do a breadth -first search on the graph starting from vertex A, and terminate once we encounter vertex B. On the resulting breadth-first spanning tree, the path from root vertex A to vertex B is the path with the least number of transit times. The vertices between A and B on the path are the number of transfer stations of the path, but it is only the shortest path problem of the simplest graph.

Design requirements

Design a traffic consulting system that allows passengers to consult the shortest route (mileage) or the minimum cost or minimum time     from any city vertex to another city vertex . For different consulting requirements, you can input the distance between cities or the required time or required cost.

    The design is divided into three parts, one is to establish the storage structure of the traffic network graph; the other is to solve the single-source shortest path problem; finally, to realize the shortest path problem between two city vertices.

[My analysis]:
        It is enough to use the adjacency list of the graph to realize it, and the algorithm is to use the Floyd algorithm. It can solve the distance between a single source and any two cities in one fell swoop, and the weight is three.

System display

After executing the code, you will directly enter the main menu interface without logging in.

Test function 1, query city routes:

If the route does not exist it will be displayed:

Test function 2, view all routes:

Because the route data we are looking for is relatively large, and the function of changing pages has not been realized, the display is relatively full.

Test function 3, query reachable cities:

Test function four, enter the administrator interface:

When entering the administrator interface for the first time, because the administrator account is not saved in the file, we need to register before entering the administrator interface. Moreover, after registering the account, we still need to log in instead of directly entering administrator interface. Of course, after you have an administrator account in the file, you will not be asked to register, but log in directly.

(You need to log in after registering the password) Successfully enter the administrator interface:

Test administrator function 1, modify password:

First enter 7 to view the administrator account.

In the file:

Generally speaking, any administrator cannot view the administrator's username and account password, but for the convenience of testing and making the system more friendly, we have set up the function of viewing the administrator.

Then we modify the password:

Check again:

The data in the file has also been modified:

You can see that the password has been successfully changed.

Then test admin function two, modify/update route:

First enter 4 to view the data in the route:

Then we modify the data of the first route:

To view:

As you can see, the first route has been successfully modified.

However, if the entered city name is not found in the file, the system will prevent the modification of the route:

Test administrator function 3, add route:

Check out the route:

It can be seen that the sixth line of the route has already displayed the newly added route, indicating that the route has been added successfully.

Test administrator function six, register administrator account:

Check again, indicating that the registration is successful.

We have a limit on the number of administrators, which cannot exceed ten. When there are already ten administrators, administrator account registration cannot be performed:

Test administrator function eight, register administrator account:

To view:

Indicates that the account has been successfully canceled.

Test administrator function nine, modify the administrator username:

Check:
 

Test administrator function five, exit the administrator interface:

When exiting the administrator interface, it will directly return out of the administrator interface function, and then re-enter the administrator interface (just like returning to the previous layer recursively).

Finally, test the function 0 of the main menu interface and exit the consulting system:

Bugs in the process of writing code

        1. Because the head insertion method is used when inserting the adjacency list, the file path will be inverted every time the file is saved, so it is solved after changing to the tail insertion method.

        2. Others are some bugs that appear during debugging. (I can’t find any bugs that can be said. Indeed, the writing process feels quite smooth, probably because of my experience)

Insignificant bugs that I think exist

        1. There are no specific restrictions on administrator user names, account numbers, and passwords.

        2. There are no specific restrictions on the city names and three weights in the picture. (burst int)

        Obviously, there is basically no need to solve these bugs. I am also lazy. Generally, the toll, mileage and time of the route will explode int.

source code

        Click here to get the source code (actually another blog, free)

references

[1] Edited by Chen Yue; edited by He Qinming et al. Data Structure [M]. Higher Education Press (Second Edition), 2016.6

[2] Grading over here! ! ! .C language file read and write operations (detailed explanation).

C language file read and write operations (detailed explanation)_Come here! ! ! Blog-CSDN blog_c language file reading and writing . 2022.5.4.

[3]HawaiiHello.C language hidden password effect realization.

Realization of hidden password effect in C language

[4] Milo Yip. How to draw " heart shape" in C language? .

How to draw a "heart shape" in C language? - Zhihu (zhihu.com) .2022.5.4

[5] Coder802.C language to get the current date and time.

C language to get the current date and time_Coder802's blog-CSDN blog_c to get the current date and time .

(Does it count if I refer to my own blog...)

epilogue

        Well, because I don't have much time, it's already the end of the semester, so I can only finish writing quickly in order not to fail the subject, and then go to review. The source code is provided for free, so can you ask for a thumbs up [poor.jpg]

Added on January 10, 2023

        I don’t know why, but I found that many people want files. Actually, the data in it is written casually, and the data is also made by hand. It’s good to follow a certain format, but I’ll put mine here, just dozens of pieces of data. Just copy the data and save it to the path.txt file in the project directory.

北京 上海 1000 1000 1000
北京 南京 1000 650 540
北京 济南 420 280 180
北京 杭州 1300 850 840
北京 天津 150 100 120
北京 青藏高原 1000 2000 999
北京 广西 1000 1000 100
上海 桂林 1500 850 840
上海 厦门 1000 750 480
上海 成都 2000 1100 1200
上海 杭州 200 150 120
上海 南京 300 150 180
上海 贵阳 1800 1000 960
上海 贵港 1800 1150 870
南京 遵义 1500 1000 780
南京 贵阳 1600 900 750
南京 贵港 1600 1050 690
南京 厦门 1100 850 570
南京 杭州 300 150 120
济南 厦门 1600 950 810
杭州 厦门 900 550 390
杭州 天津 1100 750 450
杭州 南宁 1700 1100 306
天津 厦门 2000 1300 1080
桂林 贵阳 460 270 210
桂林 贵港 320 150 90
厦门 遵义 1500 800 720
厦门 贵阳 1500 800 600
厦门 贵港 1050 650 510
厦门 成都 1900 1250 1110
厦门 南宁 1200 750 600
成都 遵义 550 360 240
成都 贵阳 660 300 240
成都 贵港 1300 650 630
贵阳 遵义 160 70 60
贵阳 南宁 580 350 240
贵港 遵义 800 550 360
贵港 南宁 150 85 42
遵义 南宁 700 400 360

Added on June 2, 2023

        Just put my practice report here, and remove some of the personal information. Go to the personal information version of the data structure experiment report

        Well, in fact, there are not many things, and they are all written in a word count. Just take a look. It would be better to be helpful.

Guess you like

Origin blog.csdn.net/xiexieyuchen/article/details/125014789