X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fgraph%2Fedge.rb;fp=lib%2Fgraph%2Fedge.rb;h=e783d354b42241eba9065fd458c7df514edd1e6a;hb=ae1a87dd7453fbafe86a4d9e5113af7439e5981f;hp=c579a2f6cbf27188406c9121a900aae27c6353f4;hpb=a4531e10dbf7fb6e199fc9a63dc9bcd329c76d99;p=graph.njae.git

diff --git a/lib/graph/edge.rb b/lib/graph/edge.rb
index c579a2f..e783d35 100644
--- a/lib/graph/edge.rb
+++ b/lib/graph/edge.rb
@@ -1,6 +1,14 @@
 require 'ostruct'
 
+# A simple graph library
+
 module Graph
+  
+  # An edge (or multiedge) in a graph. The edge can have arbitrary attributes,
+  # treated as method names.
+  #
+  # Each connection is handled by a Graph::Connection object, so that each end
+  # of the Edge can have it's own attributes.
   class Edge < OpenStruct
     def initialize
       super
@@ -8,6 +16,7 @@ module Graph
       self
     end
     
+    # Connect this edge to a vertex
     def <<(other)
       c = Connection.new
       c.end = other
@@ -15,15 +24,19 @@ module Graph
       self
     end
     
+    # Return the set of vertices this edge connects.
     def vertices
       self.connections.map {|c| c.end}
     end
     
+    # Return the connection object that joins this Edge to the specified Vertex
     def connection_at(vertex)
       self.connections.select {|c| c.end.equal?  vertex}.first
     end
   end
   
+  # A connection between an Edge and a Vertex.The connection can have arbitrary attributes,
+  # treated as method names.
   class Connection < OpenStruct
     def initialize
       super