code: def add_node(self, node, weight=None):
          if isinstance(node, tuple) and len(node) == 2 and isinstance(node[1], dict):
              node, attrs = node
              if attrs.get('weight', None) is not None:
                  attrs['weight'] = weight
          else:
              attrs = {'weight': weight}
          super(DAG, self).add_node(node, weight=weight)