for edge in ebunch:
if not (isinstance(edge[0], str) and isinstance(edge[1], str)):
raise TypeError("Name of nodes must be strings")
if edge[0] == edge[1]:
raise Exceptions.SelfLoopError("Self Loops are"
" not allowed", edge)
After Change
def __init__(self, ebunch=None):
if ebunch is not None:
self._check_node_string(set(itertools.chain(*ebunch)))
// for edge in ebunch:
// if not (isinstance(edge[0], str) and isinstance(edge[1], str)):
// raise TypeError("Name of nodes must be strings")