Module: Entity::Adjacent

Defined in:
lib/rbbt/network/paths.rb

Instance Method Summary collapse

Instance Method Details

#path_to(adjacency, entities, threshold = nil, max_steps = nil) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/rbbt/network/paths.rb', line 142

def path_to(adjacency, entities, threshold = nil, max_steps = nil)
  if Array === self
    self.collect{|gene| gene.path_to(adjacency, entities, threshold, max_steps)}
  else
    if adjacency.type == :flat
      max_steps ||= threshold
      Paths.dijkstra(adjacency, self, entities, max_steps)
    else
      Paths.weighted_dijkstra(adjacency, self, entities, threshold, max_steps)
    end
  end
end

#random_paths_to(adjacency, l, times, entities) ⇒ Object



155
156
157
158
159
160
161
162
163
164
165
# File 'lib/rbbt/network/paths.rb', line 155

def random_paths_to(adjacency, l, times, entities)
  if Array === self
    self.inject([]){|acc,gene| acc += gene.random_paths_to(adjacency, l, times, entities)}
  else
    paths = []
    times.times do 
      paths << Paths.random_weighted_dijkstra(adjacency, l, self, entities)
    end
    paths
  end
end