      def __str__(self):
          return str(self.id)
  
      def add_neighbor(self, neighbor, weight=0):
          self.adjacent[neighbor] = weight
  
  
  class Graph:
  
      def __init__(self):
 
</s> remove     def __str__(self):
        return str(self.id)
 </s> add     def __repr__(self):
        return str(self.key)

    def __lt__(self, other):
        return self.key < other.key </s> remove         self.adjacent = {}  # key = node, val = weight
 </s> add         self.incoming_edges = 0
        self.adj_nodes = {}  # Key = key, val = Node
        self.adj_weights = {}  # Key = key, val = weight </s> remove         self.nodes = {}  # key = node id, val = node

    def add_node(self, id):
        node = Node(id)
        self.nodes[id] = node
        return node

    def add_edge(self, id_source, id_dest, weight=0):
        if id_source not in self.nodes:
            self.add_node(id_source)
        if id_dest not in self.nodes:
            self.add_node(id_dest)
        self.nodes[id_source].add_neighbor(self.nodes[id_dest], weight)

    def add_undirected_edge(self, source, dest, weight=0):
        self.add_edge(source, dest, weight)
        self.nodes[dest].add_neighbor(self.nodes[source], weight) </s> add  </s> remove     def __init__(self, id):
        self.id = id
 </s> add     def __init__(self, key):
        self.key = key </s> remove     "    def __str__(self):\n",
    "        return str(self.id)\n",
 </s> add     "    def __lt__(self, other):\n",
    "        return self.key < other.key\n",
        if neighbor is None:
            raise Exception('Invalid neighbor')
        neighbor.incoming_edges += 1
        self.adj_weights[neighbor.key] = weight
        self.adj_nodes[neighbor.key] = neighbor

    def remove_neighbor(self, neighbor):
        if neighbor is None:
            raise Exception('Invalid neighbor')
        if neighbor.key in self.adj_nodes:
            neighbor.incoming_edges -= 1
            del self.adj_weights[neighbor.key]
            del self.adj_nodes[neighbor.key]
        else:
            raise Exception('Invalid neighbor')
      def __str__(self):
          return str(self.id)
  
      def add_neighbor(self, neighbor, weight=0):
        if neighbor is None:
            raise Exception('Invalid neighbor')
        neighbor.incoming_edges += 1
        self.adj_weights[neighbor.key] = weight
        self.adj_nodes[neighbor.key] = neighbor

    def remove_neighbor(self, neighbor):
        if neighbor is None:
            raise Exception('Invalid neighbor')
        if neighbor.key in self.adj_nodes:
            neighbor.incoming_edges -= 1
            del self.adj_weights[neighbor.key]
            del self.adj_nodes[neighbor.key]
        else:
            raise Exception('Invalid neighbor')
  
  
  class Graph:
  
      def __init__(self):
keep keep keep keep replace keep keep keep keep keep
 Rework graph challenge and solution (#90) 
graphs_trees/graph/graph.py