X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=lib%2Fgraph%2Fgraph.rb;fp=lib%2Fgraph%2Fgraph.rb;h=c9d83b16c6d1ea152a36a77caaf38d7318be7ffa;hb=624e339a169bd96eb01da7288a8904e0d1830e42;hp=0000000000000000000000000000000000000000;hpb=7f38e9910061e8a71db6dac57327ca1f5d3c27cd;p=graph.njae.git diff --git a/lib/graph/graph.rb b/lib/graph/graph.rb new file mode 100644 index 0000000..c9d83b1 --- /dev/null +++ b/lib/graph/graph.rb @@ -0,0 +1,21 @@ +require 'ostruct' + +module Graph + class Graph < OpenStruct + def initialize + super + self.edges = Array.new + self.vertices = Array.new + self + end + + def <<(other) + if other.class == Vertex + self.vertices << other + elsif + self.edges << other + end + self + end + end +end