Data structure Practice project--shortest path and topological sequence

Source: Internet
Author: User

This article is for the 2nd set of practice routines for [Data Structure Basic series (7): Diagram].

(Graph.h in the program is the header file in the algorithm library of the graph storage structure, click the link ... )

0710 Concept of Spanning tree
Primm algorithm of 0711 minimum spanning tree
Kruskal algorithm of 0712 minimum spanning tree
0713 Shortest path from one vertex to the remaining vertices
0714 shortest path between each pair of vertices
0715 topology sequencing
0716 AOE Network and critical path

On paper: "Knowledge principle" test questions
1, for the following figure 1:
(Fig. 1)
(1) write the adjacency matrix of the graph;
(2) The minimum spanning tree is constructed according to the idea of prim algorithm;
(3) Control the implementation of the prim algorithm, as the value of the parameter G, with the "painting a picture" of the route, go through the algorithm, draw lowest[] and closest[] Two auxiliary array of change process, "observe" algorithm execution process, so as to achieve the purpose of mastering the algorithm;
(4) The minimum spanning tree is constructed according to the idea of Kruskal algorithm;
(5) Control the implementation of the Kruskal algorithm, as the value of the parameter G, with the "painting a picture" of the route, go through the algorithm, draw e[] and vest[] Two auxiliary array of change process, "observe" algorithm execution process, achieve the purpose of mastering the algorithm;
2, for the following figure 2
(Fig. 2)
(1) write the adjacency matrix of the graph;
(2) According to the steps of the Dijkstra algorithm, the shortest path from vertex 0 to all remaining vertices is obtained.
3, a township has a, B, C, D four villages, figure 3 identifies the distance between the villages. Now to build a central club in a village, use the Floyd algorithm
(Fig. 3)
(1) Finding the shortest path between villages;
(2) The location of the club should make the distance between the village and the club the smallest, which village to choose?
(3) write down the path and path length of each village to the center club.
4, for the following figure 4, as much as possible to write its topological sequence
(Fig. 4)

On-machine practice after class
The "Project-validation algorithm" runs the algorithms described in this week's video, observing the results and understanding the algorithms.
(1) Validation of the prim algorithm (using Figure 1 as a test case)
(2) Validation of the Kruskal algorithm (using Figure 1 as a test case)
(Fig. 1)
[Refer to answer: (1) (2)]

(3) Validation of the Dijkstra algorithm (using Figure 2 as a test case)
(Fig. 2)
[Reference Solution]

(4) Floyd algorithm validation (using Figure 3 as a test case)
(Fig. 3)
[Reference Solution]

(5) Topology sequencing algorithm validation (using Figure 4 as a test case)
(Fig. 4)
[Reference Solution]

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Data structure Practice project--shortest path and topological sequence

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.