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



134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/rbbt/network/paths.rb', line 134

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



147
148
149
150
151
152
153
154
155
156
157
# File 'lib/rbbt/network/paths.rb', line 147

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