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

Автор otero1991, 13 лет назад, По-английски

I'm trying to find an algorithm for computing a minimum diameter spanning tree of a graph or just the length of the diameter of a minimum diameter spanning tree. There is a problem on SPOJ related with this:(http://www.spoj.com/problems/MDST) . I wonder if somebody could help me to find some information about this.

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

»
13 лет назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится

there are 1000 vertexes , but my way is n^3 ,so let's wait for some cows to reply

»
13 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

http://www.spoj.com/problems/PT07C/ i think this problem is a similar problem , but there are only 200 nodes

»
13 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

It's solvable in O(nm) [submit_id = 9109775, running_time = 0.77].

For each vertex v do bfs(v), so you have all distances d[i, j].

After it brute force center of MDST (it's a vertex or an edge).

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

Can anybody give a proof why calculating only shortest path tree for all nodes as a root gives us a correct output? Their are many other tree configurations possible,which might give us the shortest diameter.

EDIT:In context to THIS Thank you.

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

Are you sure calculating shortest path tree for every vertex logic is correct ? I implimented it for this problem ->http://www.spoj.com/problems/PT07C/ but got WA . http://ideone.com/YDRLYF

  • »
    »
    11 лет назад, скрыть # ^ |
    Rev. 5  
    Проголосовать: нравится 0 Проголосовать: не нравится

    "After it brute force center of MDST (it's a vertex or an edge)."

    You should check not only vertices, but also pairs of adjacent vertices.
    Look at the graph 1-2-3-4. The center of a graph is an edge between vertices 2 and 3.
    Bruteforce all edges. Do not run bfs for each edge. Calculate distance via
    dist[(edge (a, b))][i] = min(dist[a][i], dist[b][i]);

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

In case anyone wants to learn about Min. Diameter Spanning Tree (MDST) on a weighted graph, here's a very good resource: Explanation of problem C in pdf.

Here's a problem that requires this idea: 266D - BerDonalds