Class: Theseus::Algorithms::Kruskal::TreeSet

Inherits:
Object
  • Object
show all
Defined in:
lib/theseus/algorithms/kruskal.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTreeSet

Returns a new instance of TreeSet.



19
20
21
# File 'lib/theseus/algorithms/kruskal.rb', line 19

def initialize
  @parent = nil
end

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



17
18
19
# File 'lib/theseus/algorithms/kruskal.rb', line 17

def parent
  @parent
end

Instance Method Details

#connect(tree) ⇒ Object



31
32
33
# File 'lib/theseus/algorithms/kruskal.rb', line 31

def connect(tree)
  tree.root.parent = self
end

#connected?(tree) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/theseus/algorithms/kruskal.rb', line 27

def connected?(tree)
  root == tree.root
end

#rootObject



23
24
25
# File 'lib/theseus/algorithms/kruskal.rb', line 23

def root
  @parent ? @parent.root : self
end