class  DVHop(FloodingUpdate):
def  initiator_condition(self, node):
  node.memory[self.truePositionKey] = node.compositeSensor.read(node).get(‘TruePos’,None)
  return  node.memory[self.truePositionKey] is not  None
def  initiator_data(self, node):
  return{node: concatenate((node.memory[self.truePositionKey][:2],[1]))}
def  handle_flood_message(self, node, message):
  if not  node.memory.has_key(self.dataKey):
    node.memory[self.dataKey] =
  updated_data =
  for  landmark, landmark_data  in  message.data.items():
   if  landmark==node: continue
   # update only if data is new or new hopcount is smaller
   if not  node.memory[self.dataKey].has_key(landmark) or
     landmark_data[2]<node.memory[self.dataKey][landmark][2]:
    node.memory[self.dataKey][landmark] = array(landmark_data)
    # increase hopcount
    landmark_data[2] += 1
    updated_data[landmark] = landmark_data
  # landmarks should recalculate hopsize
  if  node.memory[self.truePositionKey] is not  None:
   self.recalculate_hopsize(node)
   return  updated_data
Listing 2: APS DV-hop 1st phase: DVHop. Function recalculate_hopsize is omitted. Note that during initiator_condition node reads TruePosSensor if it has one.