Class: Mst

Inherits:
Object
  • Object
show all
Defined in:
lib/mst.rb

Defined Under Namespace

Classes: Kruskal, Prim

Class Method Summary collapse

Class Method Details

.mst(algorithm = 'prim') ⇒ Object

Perform minimum spanning tree

Example:

>> Mst.mst('prim')

Arguments:

algorithm: (String)


12
13
14
15
16
17
18
19
20
# File 'lib/mst.rb', line 12

def self.mst(algorithm = 'prim')
  algo = case algorithm
           when 'kruskal'
             Mst::Kruskal
           else
             Mst::Prim
         end
  algo.mst
end