File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -134,11 +134,7 @@ impl Dsu {
134134 /// - $O(\alpha(n))$ amortized
135135 pub fn leader ( & mut self , a : usize ) -> usize {
136136 assert ! ( a < self . n) ;
137- if self . parent_or_size [ a] < 0 {
138- return a;
139- }
140- self . parent_or_size [ a] = self . leader ( self . parent_or_size [ a] as usize ) as i32 ;
141- self . parent_or_size [ a] as usize
137+ self . _leader ( a)
142138 }
143139
144140 /// Returns the size of the connected component that contains the vertex $a$.
@@ -186,6 +182,14 @@ impl Dsu {
186182 . filter ( |x| !x. is_empty ( ) )
187183 . collect :: < Vec < Vec < usize > > > ( )
188184 }
185+
186+ fn _leader ( & mut self , a : usize ) -> usize {
187+ if self . parent_or_size [ a] < 0 {
188+ return a;
189+ }
190+ self . parent_or_size [ a] = self . _leader ( self . parent_or_size [ a] as usize ) as i32 ;
191+ self . parent_or_size [ a] as usize
192+ }
189193}
190194
191195#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments