X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=lib%2Fgraph.njae%2Fedge.rb;fp=lib%2Fgraph.njae%2Fedge.rb;h=f3efc91eec9157301ece98c735663d2c94f0d1c8;hb=95b8572d01c0b9c3aa8fc5a1e85a045c33d4ecf1;hp=4a1ba790d4f33570f53525cbd3f3c23660135240;hpb=32518a2c5089dbd3b9f74aad780ded127e3040ea;p=graph.njae.git diff --git a/lib/graph.njae/edge.rb b/lib/graph.njae/edge.rb index 4a1ba79..f3efc91 100644 --- a/lib/graph.njae/edge.rb +++ b/lib/graph.njae/edge.rb @@ -34,6 +34,20 @@ module GraphNjae def connection_at(vertex) self.connections.find {|c| c.end.equal? vertex} end + + # 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 + '' + end end # A connection between an Edge and a Vertex.The connection can have arbitrary attributes,