class AbstractGraph::Composition::Edge
public Edge
class
Attributes
name[R]
vertices[RW]
Public Class Methods
new( *args )
click to toggle source
d: Create an edge with a name and two vertices a: Check if a string is passed, otherwise, the next two must be the vertices t: constant p: name if we want to name our edge, otherwise it’ll be “”
The next two args are the two vertices that this edge connects
r: Edge
object
# File lib/abstract_graph/composition/edge/initialize.rb, line 13 def initialize ( *args ) if args[0].class == String @name = args[0] else @name = "" end @vertices = args[-2, 2] end
Public Instance Methods
is_coincident?(e)
click to toggle source
d: Check if two edges are covering the same vertices. a: Compare the object_id, by extracting them and sorting them. t: constant p: Edge
e is the comparing edge r: true or false depending on coincident
# File lib/abstract_graph/composition/edge/is_coincident.rb, line 12 def is_coincident? e return e.vertices.map{|v| v.object_id}.sort == @vertices.map{|v| v.object_id}.sort end
name=(name)
click to toggle source
d: Set the name of edge. a: Throw an ArgumentError if the name is not a string t: constant p: name should be string r: The name
# File lib/abstract_graph/composition/edge.rb, line 16 def name=(name) raise ArgumentError if name.class != String @name = name end