Regenerate gemspec for version 0.2.0
[graph.njae.git] / lib / graph.njae / graph.rb
diff --git a/lib/graph.njae/graph.rb b/lib/graph.njae/graph.rb
new file mode 100644 (file)
index 0000000..1da5297
--- /dev/null
@@ -0,0 +1,27 @@
+require 'ostruct'
+
+# A simple graph library
+
+module GraphNjae
+  
+  # A container for all the parts of a graph.  The graph can have arbitrary attributes,
+  # treated as method names.
+  class Graph < OpenStruct
+    def initialize
+      super
+      self.edges = Array.new
+      self.vertices = Array.new
+      self
+    end
+    
+    # Add a Vertex or Edge to the graph.
+    def <<(other)
+      if other.class == Vertex
+        self.vertices << other
+      elsif
+        self.edges << other
+      end
+      self
+    end
+  end
+end