Simple generic graphs and operations on them in Ruby