#!/usr/local/bin/ruby class Graph attr :vertices attr :edges def initialize(vertices = [], edges = Hash.new { Hash.new {0} }) @vertices = vertices @edges = edges end end def grow(graph, a, b) vertices = graph.vertices.dup edges = graph.edges.dup vertices << vertices.size edges[a][b] += 1 edges[b][a] += 1 Graph.new(vertices , edges) end g = Graph.new([0, 1]) p g