# create network with degree 9
In [1]: netgen = NetworkGenerator(n_min=100,n_max=300,degree=9)
In [2]: net = netgen.generate()
# select landmarks by placing TruePosSensor on them
In [3]: for  node  in  net.nodes()[:10]:
     ....:  node.compositeSensor = CompositeSensor((‘TruePosSensor’))
# import algorithms and pass them to network with their parameters
In [4]: from  pymote.algorithms.niculescu2003.dvhop  import  DVHop
In [5]: from  pymote.algorithms.niculescu2003.trilaterate  import
  Trilaterate
In [6]: net.algorithms =
     ....: ((DVHop,
     ....:    {‘dataKey’: ‘dvData’,
     ....:‘truePositionKey’:‘landmarkPos’,
     ....:‘hopsizeKey’:‘hopsize’,
     ....:    }),
     ....:  (Trilaterate,
     ....:    {’dataKey’: ‘dvData’,
     ....: ‘positionKey’:‘dvHop’,
     ....: ‘truePositionKey’:‘landmarkPos’,
     ....: ‘hopsizeKey’:‘hopsize’,
     ....:    }),
     ....:    )
In [7]: sim = Simulation(net)
In [8]: sim.run()
INFO   [simulation.py]: Simulation  has  finished.
# save network with all relevant data on disk
In [9]: write_npickle(net,’net.gz’)
Listing 4: Interactive session for preliminary algorithm simulations. First we set up a random network in a default environment. Since in the original article presenting the algorithm there is network with 200 randomly distributed nodes and average degree 9 we set up NetworkGenerator with similar settings to get the appropriate instance of Network. After that, algorithms implemented in the last subsection are instantiated and placed in this new network. Since algorithms require some nodes to know their position (landmarks) we fit first 10 nodes with the appropriate sensor using simple for loop. Network is now ready so after instantiation of new Simulation we can run it. At the end by serializing and storing network object all relevant data is preserved to be analyzed later.