class ConstantDegreeConnectStrategy
Attributes
average_degree[RW]
Public Class Methods
new()
click to toggle source
# File lib/gimuby/genetic/archipelago/connect_strategy/constant_degree_connect_strategy.rb, line 5 def initialize @average_degree = 4.0 end
Public Instance Methods
connect(archipelago)
click to toggle source
# File lib/gimuby/genetic/archipelago/connect_strategy/constant_degree_connect_strategy.rb, line 11 def connect(archipelago) nodes = get_nodes(archipelago) # This won't create a graph where all nodes have same degree # since we may try to connect the same node twice number_times = (@average_degree.to_f / 2.0).round number_times.times do |_| archipelago.connect_path(nodes.shuffle!, TRUE) end end