+
+ describe 'other_end' do
+ it 'returns the vertex at the other end of the given one' do
+ e.connections.should be_empty
+ e << v1 << v2
+
+ e.other_end(v1).should be v2
+ e.other_end(v2).should be v1
+ end
+
+ it 'returns the same vertex in a self-loop' do
+ e.connections.should be_empty
+ e << v1 << v1
+
+ e.other_end(v1).should be v1
+ end
+
+ it 'returns one of the connected edges if given a vertex not connected to it' do
+ e.connections.should be_empty
+ e << v1 << v2
+
+ [v1, v2].should include e.other_end(v3)
+ end
+
+ it 'returns nil if it cannot return something sensible' do
+ e.other_end(v1).should be_nil
+ e << v1
+ e.other_end(v1).should be_nil
+ end
+ end # other_end
+
+ describe '#to_dot' do
+ it 'describes an edge in dot notation' do
+ e << v1 << v2
+ e.to_dot.should == "#{v1.object_id.to_s} -- #{v2.object_id.to_s};"
+ end
+
+ it 'describes an edge in dot notation, using given attributes' do
+ e << v1 << v2
+ e.name = 'Edge name'
+ edot = e.to_dot :label => :name
+ edot.should == "#{v1.object_id.to_s} -- #{v2.object_id.to_s} {label = \"#{e.name}\"};"
+ end
+
+ it 'describes an edge in dot notation, given a block' do
+ e << v1 << v2
+ e.to_dot {|e| e.object_id.to_s}.should == e.object_id.to_s
+ end
+ end # dot