コード例 #1
0
class Node(ABC):

    # we need unique ids for each node, for SVG output,
    # svg_id_counter provides this facility.
    svg_id_counter = Counter().next

    @staticmethod
    def reset_counter():
        Node.svg_id_counter = Counter().next

    @abstractmethod
    def __init__(self):
        raise NotImplementedError

    @abstractmethod
    def __iter__(self):
        raise NotImplementedError
コード例 #2
0
class Edge:

    # we need unique ids for each edge, for SVG output,
    # svg_id_counter provides this facility.
    svg_id_counter = Counter().next

    def __init__(self, source, target):
        self.source = source
        self.target = target
        self.svg_id = 'edge_' + str(Edge.svg_id_counter())

    def __iter__(self):
        for key in {'source', 'target'}:
            yield (key, getattr(self, key))

    @staticmethod
    def reset_counter():
        Edge.svg_id_counter = Counter().next
コード例 #3
0
 def reset_counter():
     Node.svg_id_counter = Counter().next
コード例 #4
0
 def reset_counter():
     Edge.svg_id_counter = Counter().next