Simply a directed pair (source -> target). Most library functions try do omit to instantiate edges. They instead use two vertex parameters for representing edges (see each_edge). If a client wants to store edges explicitly DirecteEdge or UnDirectedEdge instances are returned (i.e. Graph#edges).
Can be used to create an edge from a two element array.
# File lib/rgl/base.rb, line 30 def self.[](*a) new(a[0],a[1]) end
Create a new DirectedEdge with source a and target b.
# File lib/rgl/base.rb, line 35 def initialize (a,b) @source, @target = a,b end
Sort support is dispatched to the <=> method of Array
# File lib/rgl/base.rb, line 63 def <=> e self.to_a <=> e.to_a end
Two directed edges (u,v) and (x,y) are equal iff u == x and v == y. eql? is needed when edges are inserted into a Set. eql? is aliased to ==.
# File lib/rgl/base.rb, line 41 def eql?(edge) source == edge.source and target == edge.target end
Returns (v,u) if self == (u,v).
# File lib/rgl/base.rb, line 47 def reverse self.class.new(target, source) end
Returns the array [source,target].
# File lib/rgl/base.rb, line 60 def to_a; [source,target]; end
DirectedEdge.to_s == "(1-2)"
# File lib/rgl/base.rb, line 56 def to_s "(#{source}-#{target})" end
Generated with the Darkfish Rdoc Generator 2.