Блог пользователя 0xA28

Автор 0xA28, история, 9 лет назад, По-английски

Given positively weighted undirected graph G find a Spanning tree T which has the smallest possible diameter. (Tree diameter :is the maximum path over all the Shortest paths in the tree) Example Problems :

http://www.spoj.com/problems/PT07C/

http://www.spoj.com/problems/MDST/

I couldn't find any proper explanation for a solution to this problem, However i observed some cool stuff; if the graph we are dealing with was unweighted graph then we can solve this problem by bruteforcing every possible node and edge(cutting it with dummy node) and assume it as the center of our MDST then get SPT(shortest path tree) from this node and calculate it's diameter, The true MDST will be the one SPT which has the smallest diameter.

But in the Weighted Graph, things will be a little bit different when we try to cut an edge to place our dummy node, Where we should place it to get our MDST ? and is there more than a MDST or just a unique one ?

Note : i found this code by chance, but i couldn't manage to understand it

https://github.com/Malatawy15/Algorithms-Library/blob/master/Libraries/Minimum%20Diameter%20Spanning%20Tree.cpp

  • Проголосовать: нравится
  • +19
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by 0xA28 (previous revision, new revision, compare).

»
9 лет назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

I couldn't find a solution. I hope someone else would help.

»
9 лет назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

Notes:-

*The shortest path tree (SPT) from a single node could be easily constructed using any SSSP (single source shortest path) algorithm like dijkstra.

*The Center of MDST is the general node ( original node or dummy node ) which gets the SPT with the shortest possible tree diameter, in another words; given the diameter of the MDST with length L, the Center will be the General node which placed on the median position on that diameter (L / 2).

»
5 лет назад, # |
Rev. 2   Проголосовать: нравится +8 Проголосовать: не нравится

Refer to problem C in this resource. It provides a O(n*m) $$$O(n^{3})$$$ algorithm for MDST on weighted graphs.

Similar problem on Codeforces: 266D — BerDonalds. Here is my implementation in C++: 72562015

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится +10 Проголосовать: не нравится

    It's funny how in the editorial they say that the complexity of the algorithm is obviously $$$O(n \cdot m)$$$, whereas obviously the first line of the algorithm is applying the Floyd-Warshall algorithm :).