Method: Plexus::GraphBuilder#initialize
- Defined in:
- lib/plexus/graph.rb
#initialize(*params) ⇒ Graph
Creates a generic graph.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/plexus/graph.rb', line 34 def initialize(*params) raise ArgumentError if params.any? do |p| # FIXME: checking wether it's a GraphBuilder (module) is not sufficient # and the is_a? redefinition trick (instance_evaling) should be # completed by a clever way to check the actual class of p. # Maybe using ObjectSpace to get the available Graph classes? !(p.is_a? Plexus::GraphBuilder or p.is_a? Array or p.is_a? Hash) end args = params.last || {} class << self self end.module_eval do # These inclusions trigger some validations checks by the way. include(args[:implementation] ? args[:implementation] : Plexus::AdjacencyGraphBuilder) include(args[:algorithmic_category] ? args[:algorithmic_category] : Plexus::DigraphBuilder ) end implementation_initialize(*params) end |