Class: Theseus::Algorithms::Kruskal::TreeSet
- Inherits:
-
Object
- Object
- Theseus::Algorithms::Kruskal::TreeSet
- Defined in:
- lib/theseus/algorithms/kruskal.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #connect(tree) ⇒ Object
- #connected?(tree) ⇒ Boolean
-
#initialize ⇒ TreeSet
constructor
A new instance of TreeSet.
- #root ⇒ Object
Constructor Details
#initialize ⇒ TreeSet
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
#parent ⇒ Object
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
27 28 29 |
# File 'lib/theseus/algorithms/kruskal.rb', line 27 def connected?(tree) root == tree.root end |
#root ⇒ Object
23 24 25 |
# File 'lib/theseus/algorithms/kruskal.rb', line 23 def root @parent ? @parent.root : self end |