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