Class: GlobalRouting
- Inherits:
-
Object
- Object
- GlobalRouting
- Defined in:
- lib/appswarm/routing/routing.rb
Instance Method Summary collapse
- #getNodePos(p) ⇒ Object
- #getRouteOrder(nodePos) ⇒ Object
-
#initialize(baseNode, network, neighborDepth = 2) ⇒ GlobalRouting
constructor
A new instance of GlobalRouting.
- #translateFromNeighborToLocal(nodePos, neighbor) ⇒ Object
Constructor Details
#initialize(baseNode, network, neighborDepth = 2) ⇒ GlobalRouting
Returns a new instance of GlobalRouting.
293 294 295 296 |
# File 'lib/appswarm/routing/routing.rb', line 293 def initialize(baseNode,network,neighborDepth=2) @myRouting=LocalRouting.new(baseNode,network,neighborDepth) @neighborRouting=(baseNode.neighbors+[baseNode]).map2hash{|n|LocalRouting.new(n,network)} end |
Instance Method Details
#getNodePos(p) ⇒ Object
298 299 300 |
# File 'lib/appswarm/routing/routing.rb', line 298 def getNodePos(p) @myRouting.getNodePos(p) end |
#getRouteOrder(nodePos) ⇒ Object
301 302 303 |
# File 'lib/appswarm/routing/routing.rb', line 301 def getRouteOrder(nodePos) @myRouting.getRouteOrder(nodePos) end |
#translateFromNeighborToLocal(nodePos, neighbor) ⇒ Object
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/appswarm/routing/routing.rb', line 305 def translateFromNeighborToLocal(nodePos,neighbor) rt=@neighborRouting[neighbor] oldDistances=rt.getDistancesForPos(nodePos) # translateDistances neighbors=@myRouting.neighbors # collect distances, that are the same newDistances=oldDistances.select{|k,v| neighbors.member?(k) } # add missing distances (neighbors-newDistances.keys).each{|n| newDistances[n]= newDistances.map_to_a{|k,v| @myRouting.distance(n,k)+v }.min } npos=@myRouting.computePosForDistances(newDistances) end |