Sub-short path and sub-small Spanning Tree

Source: Internet
Author: User
[Sub-short path]

Sub-short paths can be seen as a special case of K-short paths. for K-short paths, there are more complex methods such as the yen algorithm. For sub-short paths, there can be a simpler method. The following describes a solution for finding a short path between two vertices.

We need to find a short path between S and T for a directed Weighted Graph (each edge of an undirected graph can be regarded as two opposite directed edges, first, find the single-source shortest path of S. Traverse the directed graph, mark the edges on the shortest path, and add K to the set. Then, enumerate and delete each edge in K of the Set, find the shortest path from S to T, and record the path length value obtained each time. The minimum value is the length of the next short path.

Here we assume that the length of the next short path can be equal to the length of the shortest path. If you want to wait, you can also think that there is more than one shortest path from S to T. If we want to find a short path from S to t that is greater than the shortest path length, the answer is that after each edge deletion, it is greater than the minimum value of the shortest path length from S to T in the original shortest path.

Find the single-source shortest path using Dijkstra + heap, the time complexity of each Shortest Path is O (n * log (n + M ), therefore, the total time complexity is O (n * m * log (n + M) + m ^ 2 ). This estimation is pessimistic, because in general, the number of edges on the shortest path is much smaller than m, so the actual effect is better than expected.

  

[Secondary generation tree]

Similar to the preceding short path method, it is easy to think of an intuitive solution of "enumerative deletion of each edge of the Minimum Spanning Tree and then finding the Minimum Spanning Tree. If prim + is used for heap, The Minimum Spanning Tree time complexity is O (n * log (n + M), and the enumeration deletes an O (n) edge, the time complexity is O (n ^ 2 * log (n + M) + N * m). When the graph is very dense, it is close to O (N ^ 3 ). This method is simple and intuitive, but we have a simpler and more efficient O (N ^ 2 + M) solution. The following describes this method.

First, find the Minimum Spanning Tree of the source image, and record the sum of weights to minst. Add each edge (u, v) that is not on the minimum generation tree to the enumeration. A ring will be formed after the addition. Find the edge with the second largest weight value on the ring (that is, the edge with the largest weight value except (u, v), delete it, and calculate the sum of the weights of the current spanning tree. Take the minimum value of the sum of the generated tree weights modified by all enumeration operations, that is, the next generation tree.

In specific implementation, the simpler method is to traverse the entire minimal spanning tree from each node I, and define f [J] as the maximum edge value in the path from I to J. Traverse the graph to find the value of F [J], and then add each edge (I, j) that is not in the minimum spanning tree. The sum of the newly generated tree weights is minst + W (I, j)-f [J]. If the minimum value is recorded, the Child tree is generated.

The time complexity of this algorithm is O (n ^ 2 + M ). Because only the minimum spanning tree is used, the simplest prim can be used. The time complexity is O (n ^ 2 ). The bottleneck of the algorithm is not to find the minimum spanning tree, but to add edge modifications to the enumeration of O (N ^ 2 + M), so it is unnecessary to use a better minimum spanning tree algorithm.

  

[Example of sub-short path and sub-small Spanning Tree]

Haoi 2005 Route Selection
Directly find the next short path.

PKU 3255 roadblocks
A slightly special short path allows repeated edges.

Ural 1416 confidential
The problem of the next generation of tree,

PKU 1679 the unique MST
Determines whether the minimum spanning tree is unique.

  

[References]

  • Graph theory summary of amber

 

[Transfer] http://www.byvoid.com/blog/2-sp-mst/

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.