experiments on union find algorithms for the disjoint set
play

Experiments on Union-Find Algorithms for the Disjoint-Set Data - PowerPoint PPT Presentation

Introduction Variations of Classical Algorithms Implementation Enhancements The Fastest Algorithms Experiments on Union-Find Algorithms for the Disjoint-Set Data Structure Md. Mostofa Ali Patwary* Jean Blair** Fredrik Manne* *Department of


  1. Introduction Variations of Classical Algorithms Implementation Enhancements The Fastest Algorithms Experiments on Union-Find Algorithms for the Disjoint-Set Data Structure Md. Mostofa Ali Patwary* Jean Blair** Fredrik Manne* *Department of Informatics, University of Bergen, Norway **Department of EE and CS,United States Military Academy, USA May 20-22, 2010 SEA 2010, Italy. Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  2. Introduction Variations of Classical Algorithms Implementation Enhancements The Fastest Algorithms Overview ◮ Extensive experimental study comparing 55 different variations of Union-Find algorithm. ◮ The study includes: ◮ All the classical algorithms. ◮ Several recently suggested enhancements. ◮ Different combinations and optimizations of these. ◮ Main Result: A somewhat forgotten simple algorithm developed by M artin R em in 1976 is the fastest algorithm. Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  3. Introduction Variations of Classical Algorithms Implementation Enhancements The Fastest Algorithms Related Experimental Studies Reference Application Computing # of Algorithms [Liu, 1990] Sparse matrix Factorization 2 [Gilbert et al., 1994] Sparse matrix Factorization 6 [Wassenberg et al., 2008] Image processing Labeling 8 [Wu et al., 2009] Image processing Labeling 3 [Hynes, 1998] Graphs Connected components 18 [Osipov et al., 2009] Graphs Minimum spanning tree 2 Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  4. Introduction Variations of Classical Algorithms Implementation Enhancements The Fastest Algorithms Outline Introduction Applications and Definitions Main Operations (Union-Find) Variations of Classical Algorithms Union Techniques Compression Techniques Interleaved Algorithms Implementation Enhancements 1. Immediate Parent Check [Osipov et al., 2009] 2. Better Interleaved Algorithms [Manne and Patwary, 2009] 3. Memory Efficient Algorithms The Fastest Algorithms Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  5. Introduction Variations of Classical Algorithms Applications and Definitions Implementation Enhancements Main Operations (Union-Find) The Fastest Algorithms Disjoint-Set Data Structure: Definitions ◮ U ⇒ set of n elements and S i ⇒ a subset of U . ◮ S 1 and S 2 are disjoint if S 1 ∩ S 2 = ∅ . ◮ Maintains a dynamic collection S 1 , S 2 , . . . S k of disjoint sets which together cover U . ◮ Each set is identified by a representative x . ◮ A set of algorithms that operate on this data structure is often referred to as a Union-Find algorithm. Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  6. Introduction Variations of Classical Algorithms Applications and Definitions Implementation Enhancements Main Operations (Union-Find) The Fastest Algorithms Main Operations ◮ Each set is represented by a rooted tree, pointer towards root. a ◮ The element in the root node is d the representative of the set. b ◮ Parent pointer p ( x ) denotes the e c parent of node x . ◮ Two main operations. Figure: S i = { a , b , c , d , e } . ◮ Find ( x ). ◮ Union ( x , y ). Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  7. Introduction Variations of Classical Algorithms Applications and Definitions Implementation Enhancements Main Operations (Union-Find) The Fastest Algorithms Find ( x ) a b ◮ To which set does a given element c x belong ⇒ Find ( x ). ◮ Returns the root (representative) d of the set that contain x . e Figure: Find( d ). Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  8. Introduction Variations of Classical Algorithms Applications and Definitions Implementation Enhancements Main Operations (Union-Find) The Fastest Algorithms Union ( x , y ) a ◮ Create a new set from the union of f two existing sets containing x and d b g y ⇒ Union ( x , y ). e ◮ Change the parent pointer of one c root to the other one. Figure: Union ( c , g ). Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  9. Introduction Variations of Classical Algorithms Applications and Definitions Implementation Enhancements Main Operations (Union-Find) The Fastest Algorithms Union ( x , y ) a ◮ Create a new set from the union of f two existing sets containing x and d b g y ⇒ Union ( x , y ). e ◮ Change the parent pointer of one c root to the other one. Figure: Union ( c , g ). Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  10. Introduction Variations of Classical Algorithms Applications and Definitions Implementation Enhancements Main Operations (Union-Find) The Fastest Algorithms Use of Union-Find for Computing Connected Components: G = ( V , E ) 1: S ← ∅ 2: for each x ∈ V do ◮ Note that if the edges are Makeset ( x ) 3: processed by increasing 4: for each ( x , y ) ∈ E do weight then this algorithm is if Find ( x ) � = Find ( y ) then 5: Kruskal’s algorithm. Union ( x , y ) 6: S ← S ∪ { ( x , y ) } 7: Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  11. Introduction Union Techniques Variations of Classical Algorithms Compression Techniques Implementation Enhancements Interleaved Algorithms The Fastest Algorithms Union Techniques ◮ Naive-Link ( nl ) ◮ Link-by-Size ( ls ) ◮ Link-by-Rank ( lr ) Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  12. Introduction Union Techniques Variations of Classical Algorithms Compression Techniques Implementation Enhancements Interleaved Algorithms The Fastest Algorithms Union Techniques : Link-by-Rank ( lr ) 2 1 ◮ Each set maintains a a f rank value, intially 0. d ◮ Lowest ranked root b g ⇒ higher ranked root. e ◮ Equal ranked roots ⇒ c root of the combined tree is increased by 1. Figure: Union . Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  13. Introduction Union Techniques Variations of Classical Algorithms Compression Techniques Implementation Enhancements Interleaved Algorithms The Fastest Algorithms Union Techniques : Link-by-Rank ( lr ) 2 1 ◮ Each set maintains a a f rank value, intially 0. d ◮ Lowest ranked root b g ⇒ higher ranked root. e ◮ Equal ranked roots ⇒ c root of the combined tree is increased by 1. Figure: Union . Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  14. Introduction Union Techniques Variations of Classical Algorithms Compression Techniques Implementation Enhancements Interleaved Algorithms The Fastest Algorithms Union Techniques : Link-by-Rank ( lr ) 2 2 ◮ Each set maintains a a f rank value, intially 0. d ◮ Lowest ranked root b g ⇒ higher ranked root. e i h ◮ Equal ranked roots ⇒ c root of the combined tree is increased by 1. Figure: Union . Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  15. Introduction Union Techniques Variations of Classical Algorithms Compression Techniques Implementation Enhancements Interleaved Algorithms The Fastest Algorithms Union Techniques : Link-by-Rank ( lr ) 3 2 2 ◮ Each set maintains a a f rank value, intially 0. d ◮ Lowest ranked root b g ⇒ higher ranked root. e i h ◮ Equal ranked roots ⇒ c root of the combined tree is increased by 1. Figure: Union . Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  16. Introduction Union Techniques Variations of Classical Algorithms Compression Techniques Implementation Enhancements Interleaved Algorithms The Fastest Algorithms Compression Techniques ◮ Naive-Find ( nf ) ◮ Path-Compression ( pc ) ◮ Path-Splitting ( ps ) ◮ Path-Halving ( ph ) ◮ Type-0-Reversal ( r0 ) ◮ Type-1-Reversal ( r1 ) ◮ Collapsing ( co ) Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  17. Introduction Union Techniques Variations of Classical Algorithms Compression Techniques Implementation Enhancements Interleaved Algorithms The Fastest Algorithms Compression Techniques a ◮ Reduce the height of the tree b during the Find operation. ◮ Subsequent Find operations c require less time. d ◮ Find-path of a node x is the path of parent pointers from x upto the e root of the tree. Figure: Find-path( d ). Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

  18. Introduction Union Techniques Variations of Classical Algorithms Compression Techniques Implementation Enhancements Interleaved Algorithms The Fastest Algorithms Compression Techniques : Path-Compression ( pc ) a ◮ Set the parent b pointers of all nodes c in the find path to the root. d ◮ Need to traverse the find-path twice. e Figure: Find ( e ) with pc Md. Mostofa Ali Patwary, Jean Blair, and Fredrik Manne Experiments on Union-Find Algorithms

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend