Class: EmailGraph::UndirectedEdge

Inherits:
Object
  • Object
show all
Defined in:
lib/email_graph/undirected_graph.rb

Direct Known Subclasses

MutualRelationship

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(v, w) ⇒ UndirectedEdge

Returns a new instance of UndirectedEdge.

Raises:

  • (ArgumentError)


46
47
48
49
# File 'lib/email_graph/undirected_graph.rb', line 46

def initialize(v, w)
  raise ArgumentError, "Vertices cannot be falsy" unless v && w
  @vertices = Set.new([v, w])
end

Instance Attribute Details

#verticesObject (readonly)

Returns the value of attribute vertices.



44
45
46
# File 'lib/email_graph/undirected_graph.rb', line 44

def vertices
  @vertices
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



55
56
57
# File 'lib/email_graph/undirected_graph.rb', line 55

def ==(other)
  @vertices == other.vertices
end

#hashObject



51
52
53
# File 'lib/email_graph/undirected_graph.rb', line 51

def hash
  @vertices.hash
end

#to_sObject



60
61
62
63
# File 'lib/email_graph/undirected_graph.rb', line 60

def to_s
  a = @vertices.to_a
  "(#{a[0]}-#{a[1]})"
end