class Edge(str): """ Edge class for directed graph library. Extends string so you can use the Edge object itself to read it's label. """ def __new__(cls, edge_label, source_node, destination_node): obj = super().__new__(cls, edge_label) obj._source_node = source_node obj._destination_node = destination_node return obj def get_source(self): return self._source_node def get_destination(self): return self._destination_node