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



130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/rbbt/network/paths.rb', line 130

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



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

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