Class: AbstractGraph::Composition::Edge

Inherits:
Object
  • Object
show all
Defined in:
lib/abstract_graph/composition/edge.rb,
lib/abstract_graph/composition/edge/initialize.rb,
lib/abstract_graph/composition/edge/is_coincident.rb

Overview

public Edge class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Edge

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



13
14
15
16
17
18
19
20
# 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

Instance Attribute Details

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/abstract_graph/composition/edge.rb', line 8

def name
  @name
end

#verticesObject

Returns the value of attribute vertices.



9
10
11
# File 'lib/abstract_graph/composition/edge.rb', line 9

def vertices
  @vertices
end

Instance Method Details

#is_coincident?(e) ⇒ Boolean

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

Returns:

  • (Boolean)


12
13
14
# 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