def delete(node)
      unless @nodes.key?(node.key)
        raise NoSuchNodeError.new(node.key)
      end

      (node.edges(:out) + node.edges(:in)).each do |edge|
        edge.from.disconnect_via(edge)
        edge.to.disconnect_via(edge)
      end

      @nodes.delete(node.key)
    end
def delete(node)
      unless @nodes.key?(node.key)
        raise NoSuchNodeError.new(node.key)
      end

      (node.edges(:out) + node.edges(:in)).each do |edge|
        edge.from.disconnect_via(edge)
        edge.to.disconnect_via(edge)
      end

      @nodes.delete(node.key)
    end
Public: Removes the +node+ from the graph and disconnects any nodes
 which have edges to the +node+.

 node - The node to be deleted.

 Raises a NoSuchNodeError if the graph does not contain the given +node+.

 Returns the node.