class DiameterMeasure

Return the diameter of an archipelago If archipelago is not connex, simply output twice number of its nodes

Public Instance Methods

compute(archipelago) click to toggle source
# File lib/gimuby/genetic/archipelago/measure/diameter_measure.rb, line 10
def compute(archipelago)
  unless is_connected(archipelago)
    return 2 * archipelago.get_nodes.length
  end
  get_biggest_shortest_paths(archipelago)
end

Private Instance Methods

get_biggest_shortest_paths(archipelago) click to toggle source
# File lib/gimuby/genetic/archipelago/measure/diameter_measure.rb, line 25
def get_biggest_shortest_paths(archipelago)
  paths_lengths = get_shortest_paths_measure.compute(archipelago)
  paths_lengths.max
end
get_connected_measure() click to toggle source
# File lib/gimuby/genetic/archipelago/measure/diameter_measure.rb, line 30
def get_connected_measure
  ConnectedMeasure.new
end
get_shortest_paths_measure() click to toggle source
# File lib/gimuby/genetic/archipelago/measure/diameter_measure.rb, line 34
def get_shortest_paths_measure
  ShortestPathsMeasure.new
end
is_connected(archipelago) click to toggle source
# File lib/gimuby/genetic/archipelago/measure/diameter_measure.rb, line 19
def is_connected(archipelago)
  connected_measure = get_connected_measure
  connected_classes_count = connected_measure.compute(archipelago)
  connected_classes_count == 1
end