X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=lib%2Fgraph.njae%2Fvertex.rb;h=4a75b6df2c628c0cba8a25fead7aff670a1c1563;hb=5afeed673400a0d1e2c1c0d6b6f286f65723f405;hp=bf14dddac07ce079f13a5d4de2409d8292d449c0;hpb=c34def40508c16cfc815fa02c8743d071491af7b;p=graph.njae.git diff --git a/lib/graph.njae/vertex.rb b/lib/graph.njae/vertex.rb index bf14ddd..4a75b6d 100644 --- a/lib/graph.njae/vertex.rb +++ b/lib/graph.njae/vertex.rb @@ -31,10 +31,12 @@ module GraphNjae # Return the set of neighbouring vertices def neighbours - vertices = self.edges.map {|e| e.vertices}.flatten - vertices_to_me = vertices.select {|v| v == self} - other_vertices = vertices.select {|v| v != self} - (vertices_to_me[1..-1] || []) + other_vertices + #vertices = self.edges.map {|e| e.vertices}.flatten + #vertices_to_me = vertices.select {|v| v == self} + #other_vertices = vertices.select {|v| v != self} + #(vertices_to_me[1..-1] || []) + other_vertices# + self.edges.map {|e| e.vertices.take_while {|v| v != self} + + e.vertices.drop_while {|v| v != self}[1..-1]}.flatten end end