nodesinbranch = (node_count - 1)/ BRANCHES
c = 1
- for i in xrange(BRANCHES):
+ for i in range(BRANCHES):
prev = 0
- for n in xrange(1, nodesinbranch + 1):
+ for n in range(1, nodesinbranch + 1):
graph.add_node(c)
graph.add_edge(prev, c)
prev = c
def annotate_node(self, nid, name, value):
if not isinstance(value, str) and not isinstance(value, int) and \
not isinstance(value, float) and not isinstance(value, bool):
- raise RuntimeError, "Non-serializable annotation"
+ raise RuntimeError("Non-serializable annotation")
self.topology.node[nid][name] = value
def annotate_edge(self, nid1, nid2, name, value):
if not isinstance(value, str) and not isinstance(value, int) and \
not isinstance(value, float) and not isinstance(value, bool):
- raise RuntimeError, "Non-serializable annotation"
+ raise RuntimeError("Non-serializable annotation")
self.topology.edge[nid1][nid2][name] = value
net = ipaddr.IPv6Network(netblock)
new_prefix = 30
else:
- raise RuntimeError, "Invalid IP version %d" % version
+ raise RuntimeError("Invalid IP version %d" % version)
## Clear all previusly assigned IPs
for nid in self.topology.nodes():
source = leaves.pop(random.randint(0, len(leaves) - 1))
else:
# options must not be already sources or targets
- options = [ k for k,v in self.topology.degree().iteritems() \
+ options = [ k for k,v in self.topology.degree().items() \
if (not kwargs.get("is_leaf") or v == 1) \
and not self.topology.node[k].get("source") \
and not self.topology.node[k].get("target")]