Presentation is loading. Please wait.

Presentation is loading. Please wait.

Empirical Study on Finding Minimal Spanning Tree S. J. Shyu 4/29/2012.

Similar presentations


Presentation on theme: "Empirical Study on Finding Minimal Spanning Tree S. J. Shyu 4/29/2012."— Presentation transcript:

1 Empirical Study on Finding Minimal Spanning Tree S. J. Shyu 4/29/2012

2 演算法 6-5 Kruskal 演算法求最小延展樹 輸入:加權圖形 G = ( V, E ) , | V |= n ; w ( e ) 為邊 e 上的權重值 輸出: T , T 為 G 的最小延展樹 1 T =  ; 2 while (( T 中少於 n  1 條邊 ) && ( E !=  )) 3 { ( u, v ) = E 中最小權重的邊 ; 4 E = E \{( u, v )} ; 5 if (( u, v ) 加入 T 後不致形成迴圈 ) 6 T = T  {( u, v )} ; 7 } 8 if ( T 中邊數 <( n  1)) 印出 ” G 無延展樹! ”; 9 else 輸出 T ; using Loop using Heap using Loop using Union&Find

3 Questions What are the performances of Kruskal’s algorithm when selecting min. by loop vs. by heap? What are the performances of Kruskal’s algorithm when detecting cycles by loop vs. by union-find?

4 Experiments CPU: Intel Core i5-2400 3.10GHz RAM: 4GB OS: Windows 7 Program: BCB 2010

5 5362892273222138

6

7 10 32115 137 216294

8 18 39 68 85128

9 613 5033 63

10

11

12 Comparison of Selecting Min. by Loop and Heap in Kruskal’s Algorithm 2% 9% 18%29% 44%90% 1%

13 Remarks In Kruskal’s algorithm, selecting min. by heap is better than by loop? The superiority of using heap (over loop) grows as %edge increases. – Problems with more edges receive more benefit when using heap (than loop). Detecting cycles by union-find outperforms those by loop? The superiority of using union-find (over loop) grows as %edge decreases. – When %edge decreases, the edges incurring cycles grows so that union-find conquers loop for cycle detection.

14 Question What are the performances of Kruskal’s and Prim’s algorithms?

15

16

17 Remarks The performance of Prim’s algorithm is robust w.r.t. all kinds of problem instances. The execution time of Kruskal’s algorithm decreases as %edge decreases. Apply Prim’s algorithm when %edge is large, say >0.1 for |V|=10000; whereas Kruskal’s, otherwise.

18 Programs = Data Structures + Algorithms


Download ppt "Empirical Study on Finding Minimal Spanning Tree S. J. Shyu 4/29/2012."

Similar presentations


Ads by Google