class RGL::Edge::DirectedEdge
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 DirectedEdge
or UnDirectedEdge
instances are returned (i.e. Graph#edges
).
Attributes
source[RW]
target[RW]
Public Class Methods
[](*a)
click to toggle source
Can be used to create an edge from a two element array.
# File lib/rgl/base.rb 36 def self.[](*a) 37 new(a[0], a[1]) 38 end
new(a, b)
click to toggle source
Create a new DirectedEdge
with source a and target b.
# File lib/rgl/base.rb 42 def initialize(a, b) 43 @source, @target = a, b 44 end
Public Instance Methods
<=>(e)
click to toggle source
Sort support is dispatched to the <=> method of Array
# File lib/rgl/base.rb 89 def <=> e 90 self.to_a <=> e.to_a 91 end
[](index)
click to toggle source
eql?(edge)
click to toggle source
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 49 def eql?(edge) 50 (source == edge.source) && (target == edge.target) 51 end
Also aliased as: ==
hash()
click to toggle source
# File lib/rgl/base.rb 55 def hash 56 source.hash ^ target.hash 57 end
inspect()
Alias for: to_s
reverse()
click to toggle source
Returns (v,u) if self == (u,v).
# File lib/rgl/base.rb 61 def reverse 62 self.class.new(target, source) 63 end
to_a()
click to toggle source
Returns the array [source,target].
# File lib/rgl/base.rb 83 def to_a 84 [source, target] 85 end
to_s()
click to toggle source
DirectedEdge.to_s == “(1-2)”
# File lib/rgl/base.rb 74 def to_s 75 "(#{source}-#{target})" 76 end
Also aliased as: inspect