def add(node)
      if @nodes.key?(node.key)
        raise DuplicateNodeError.new(node.key)
      end

      @nodes[node.key] = node
    end
def add(node)
      if @nodes.key?(node.key)
        raise DuplicateNodeError.new(node.key)
      end

      @nodes[node.key] = node
    end
Public: Creates a new graph.
 Public: Adds the +node+ to the graph.

 node - The node to be added.

 Raises a DuplicateNodeError if the graph already contains a node with
 the same key.

 Returns the node.