Class: GraphElements::Vertex

Inherits:
Object
  • Object
show all
Defined in:
lib/social_framework/graphs/graph_elements.rb

Overview

Define abstract methods to Vertex

Direct Known Subclasses

VertexDefault

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, type, attributes) ⇒ Vertex

Constructor to vertex

Params:
id

Integer vertex id

type

Class of vertex

attributes

Hash aditional attributes of vertex

Returns NotImplementedError



15
16
17
# File 'lib/social_framework/graphs/graph_elements.rb', line 15

def initialize id, type, attributes
  raise 'Must implement method in subclass'
end

Instance Attribute Details

#attributesObject

The attributes of vertex



7
8
9
# File 'lib/social_framework/graphs/graph_elements.rb', line 7

def attributes
  @attributes
end

#edgesObject

The attributes of vertex



7
8
9
# File 'lib/social_framework/graphs/graph_elements.rb', line 7

def edges
  @edges
end

#idObject

The attributes of vertex



7
8
9
# File 'lib/social_framework/graphs/graph_elements.rb', line 7

def id
  @id
end

#typeObject

The attributes of vertex



7
8
9
# File 'lib/social_framework/graphs/graph_elements.rb', line 7

def type
  @type
end

Instance Method Details

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

Overriding equal method Returns NotImplementedError



21
22
23
# File 'lib/social_framework/graphs/graph_elements.rb', line 21

def ==(other)
  raise 'Must implement method in subclass'
end

#add_edge(destiny, label = "") ⇒ Object

Method to add edges to vertex

Params:
destiny

Vertex destiny to edge

label

String label to edge

Returns NotImplementedError



38
39
40
# File 'lib/social_framework/graphs/graph_elements.rb', line 38

def add_edge destiny, label = ""
  raise 'Must implement method in subclass'
end

#hashObject

Overriding hash method Returns NotImplementedError



29
30
31
# File 'lib/social_framework/graphs/graph_elements.rb', line 29

def hash
  raise 'Must implement method in subclass'
end