X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=lib%2Fgraph.njae%2Fvertex.rb;h=4ac903c2bea7f9424ab34ecb9c6a8b42a57cab88;hb=282a96d68535bd39b4dcd08ff805ccfcfd8b9f10;hp=6e46dcb40029aef8ceca16ad5c5ea2fc5a789c46;hpb=95b8572d01c0b9c3aa8fc5a1e85a045c33d4ecf1;p=graph.njae.git

diff --git a/lib/graph.njae/vertex.rb b/lib/graph.njae/vertex.rb
index 6e46dcb..4ac903c 100644
--- a/lib/graph.njae/vertex.rb
+++ b/lib/graph.njae/vertex.rb
@@ -1,5 +1,3 @@
-require 'ostruct'
-
 # A simple graph library
 
 module GraphNjae
@@ -43,5 +41,21 @@ module GraphNjae
       '<V: ' + self.name + '>'
     end
     
+    def to_dot(opts = {})
+      if block_given?
+        yield self
+      else
+        dot = self.object_id.to_s
+        if opts.size > 0
+          dot << ' {'
+          dot << opts.keys.map { |k|
+            (k.to_s + ' = "' + self.instance_eval(opts[k].to_s).to_s) + '"'
+                        }.join(', ')
+          dot << '}'
+        end
+        dot << ';'
+      end
+    end
+    
   end
 end