+
+ # Return the vertex at the other end of the one given.
+ # Self-loops should still return the vertex
+ def other_end(vertex)
+ if self.vertices[0] == vertex
+ self.vertices[1]
+ else
+ self.vertices[0]
+ end
+ end
+
+ def to_s
+ '<E: ' + self.type.to_s + ' [' + self.vertices.map {|n| n.to_s}.join(', ') + '] >'
+ end