Class: Clusta::Geometry::Edge

Inherits:
Element
  • Object
show all
Defined in:
lib/clusta/geometry/edge.rb

Direct Known Subclasses

DirectedEdge

Instance Attribute Summary

Attributes included from Schema

#extra_inputs

Instance Method Summary collapse

Methods inherited from Element

inherited

Methods included from Serialization::TSV

#extra_inputs=, #extra_outputs, included, #process_args, #suffix, #to_flat, #to_tsv_component

Methods included from Serialization::JSON

included, #non_key_field_data, #process_args, #to_flat, #to_hash

Methods included from Serialization

included, #initialize, #process_args, #stream_name

Methods included from Schema

#extra_outputs, #fields, included, #keys, #non_key_fields

Instance Method Details

#degree_of(label) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/clusta/geometry/edge.rb', line 40

def degree_of label
  case label
  when source_label then source_degree
  when target_label then target_degree
  else
    raise Error.new("This edge (#{labels_string}) does not contain vertex #{label}")
  end
end

#degreesObject



36
37
38
# File 'lib/clusta/geometry/edge.rb', line 36

def degrees
  [source_degree, target_degree]
end

#directed?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/clusta/geometry/edge.rb', line 16

def directed?
  false
end

#joins?(label) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/clusta/geometry/edge.rb', line 20

def joins? label
  source_label == label || target_label == label
end

#labels_stringObject



24
25
26
# File 'lib/clusta/geometry/edge.rb', line 24

def labels_string
  [source_label, target_label].map(&:to_s).join(' -> ')
end

#neighborObject



53
54
55
# File 'lib/clusta/geometry/edge.rb', line 53

def neighbor
  Neighbor.new(target_label, weight)
end

#reversedObject



49
50
51
# File 'lib/clusta/geometry/edge.rb', line 49

def reversed
  self.class.new(target_label, source_label, weight)
end

#source_degreeObject



28
29
30
# File 'lib/clusta/geometry/edge.rb', line 28

def source_degree
  Degree.new(source_label, 1)
end

#target_degreeObject



32
33
34
# File 'lib/clusta/geometry/edge.rb', line 32

def target_degree
  Degree.new(target_label, 1)
end

#weighted?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/clusta/geometry/edge.rb', line 12

def weighted?
  self.weight
end