[Introduction to algorithms] Minimum Spanning Tree Extension

Source: Internet
Author: User

1. Minimum Spanning Tree

Definition: Set T to the Minimum Spanning Tree of graph G. If T1 meets ω (T1) = min {ω (t') | t'ε not (t )}, then T1 is a small generation tree of G.

Explanation: apart from the Minimum Spanning Tree, the weight and Minimum Spanning Tree of the other spanning tree are defined as the minimum spanning tree.

Typical question: poj1679 the unique MST. For a graph, determine whether the minimum spanning tree is unique. The only definition is: The second spanning tree does not exist, and its weight is equal to that of the Minimum Spanning Tree. W (minimum generation tree )! = W (Minimum Spanning Tree)

Algorithm ideas: 1. A minimum spanning tree,

2. Then enumerate the edges other than the Spanning Tree. Each time an edge is added, a ring is generated.

3. Remove the maximum edge of the weight value except the newly added edge on the ring in sequence, then, determine whether the new Spanning Tree and native spanning tree have the same weight (not smaller than the original Spanning Tree)

General idea: Simply put, it is to judge whether the newly added edge has the same weight value as the edge with the largest weight value in the original edge on the ring. (Cause: the edges selected by the minimal spanning tree are the smallest weights, and the remaining edges> = the edges of the Minimum Spanning Tree)

Method 1: first obtain the minimum spanning tree, mark the edge that constitutes the minimum spanning tree, enumerate the edge, delete one at a time, then calculate the Spanning Tree, and save the value. After completing the request, add the deleted edge. For the next edge deletion, the minimum value is saved during the enumeration process. If the minimum value is equal to the value of the original Minimum Spanning Tree, the minimum value is not unique and the minimum value is unique.

Method 2: Use the prim algorithm to find a Minimum Spanning Tree. with the characteristics of the prim algorithm, the extension result is a tree for each step, to facilitate the determination of enumeration edge in the next step, we use a max array to record the maximum edge weight between any two points on the tree (here there is ambiguity, and the positive solution is: find the biggest edge among all edges between I and j. This step is easily achieved in the prim algorithm, because Max [I] [J] = max {max [I] [K], edge [k] [J]}. The next operation is to enumerate every edge that is not in the smallest spanning tree. For edge [I] [J], determine whether it is equal to Max [I] [J]. If it is equal, the minimum spanning tree is not unique.

PS: I have made some ing between Edges and vertices, which has a large space overhead and high programming complexity. I will try to write it more concisely in the future. (Update: it is easier to store questions with an adjacent matrix for a small amount of data)

Ii. minimum degree limit Spanning Tree

Definition: A minimum spanning tree with a node P degree limit of = K

Solution: 1. delete all the edges around P and find the Minimum Spanning Tree in each connected subgraph.

2. Select any edge to connect all connected subgraphs to P. At this time, a tree is formed. If the degree of P is equal to the limit, the number is the answer. If the value is greater than the limit, no solution is available. If the value is smaller than the limit, perform step 3.

3. In order to make the degree of P = K, set the current minimum spanning tree to T. Enumerate each entry (p, I )! In "T", find the weight (not directly connected to P) of "P to I" in "T" as Maxi. Delete the edge whose weight is Maxi, increase (P, I), and increase the P level by 1.

4. If the P level is still less than the limit, perform step 3.

Example: poj 1639 picnic planning (limited to the current level ......)

3. Optimal Rate Spanning Tree

Definition: each edge has two weights, namely cost and length. A tree is generated to minimize the total cost.

Example: poj 2728 desert King (limited to the current level ......)

 

 

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.