Finding the minimum spanning tree using the circle breaking Method

Source: Internet
Author: User

I am about to take the data structure examination. I can see that there is a "broken circle" in the minimal spanning tree. I didn't go into details on the Internet, so I will share my experiences.

The "circle breaking method" is actually a kind of greed.AlgorithmThe only difference is that the prim and krustal algorithms are "adding" edges, which, as the name suggests, are subtraction edges. The idea is as follows:

1. Find a circle in the graph. 2. Delete the edge with the largest weight. 3. Repeat the above operation until there is no circle in the figure.

For undirected graphs, you can do this:

1. Use the topological classification algorithm to find the circle in the graph. Specifically, find the vertices with a moderate value of 1 in the graph (which can be saved in the queue) and delete them (the deletion here is temporary, and these vertices will be restored in the next traversal ), then the inbound degree of the vertex adjacent to it is-1, so that the reciprocating operation will continue until there is no vertex with an inbound degree of 1 in the graph, that is, the degrees of all vertices are equal to 2, then all the remaining edges are in the ring. Of course, if there are no remaining edges, it means that there is no ring and the algorithm ends.

2. The remaining edges are all the edges in the ring. You can delete the biggest right edge.

3. Perform another operation until there is no circle in the figure, that is, all circles have been broken, and the rest is the minimal spanning tree.

 

It is estimated that this question cannot be obtained, so the algorithm will not be written ~

 

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.