Class: ShortestPathsMeasure

Inherits:
Measure
  • Object
show all
Defined in:
lib/gimuby/genetic/archipelago/measure/shortest_paths_measure.rb

Overview

Return the list of shortest path (Dijkstra) in Archipelago

Instance Method Summary collapse

Instance Method Details

#compute(archipelago) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/gimuby/genetic/archipelago/measure/shortest_paths_measure.rb', line 6

def compute(archipelago)
  nodes = archipelago.get_nodes
  shortest_paths_length = []
  nodes.each do |node1|
    nodes.each do |node2|
      if node2 > node1
        length = get_shortest_path_length(archipelago, node1, node2)
        unless length.nil?
          shortest_paths_length.push(length)
        end
      end
    end
  end
  shortest_paths_length
end