When a new node is added, there is a check for whether that name is already assigned to a node. However, this is done against the keys of self.names instead of the values.
def addNode(self, name=None):
...
if name is None:
name = str(n)
else:
name = str(name)
if name is not None and name in self.names: <-----------
raise ValueError("Node %s already exists" % (str(name)))
self.names[n] = name
self.nodemap[name] = n
self.out_edge_map.append(dict())
self.in_edge_map.append(dict())
return n
When a new node is added, there is a check for whether that name is already assigned to a node. However, this is done against the keys of self.names instead of the values.