Class: Clusta::Geometry::Edge
Instance Attribute Summary
Attributes included from Schema
#extra_inputs
Instance Method Summary
collapse
Methods inherited from Element
inherited
#extra_inputs=, #extra_outputs, included, #process_args, #suffix, #to_flat, #to_tsv_component
included, #non_key_field_data, #process_args, #to_flat, #to_hash
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
|
#degrees ⇒ Object
36
37
38
|
# File 'lib/clusta/geometry/edge.rb', line 36
def degrees
[source_degree, target_degree]
end
|
#directed? ⇒ Boolean
16
17
18
|
# File 'lib/clusta/geometry/edge.rb', line 16
def directed?
false
end
|
#joins?(label) ⇒ Boolean
20
21
22
|
# File 'lib/clusta/geometry/edge.rb', line 20
def joins? label
source_label == label || target_label == label
end
|
#labels_string ⇒ Object
24
25
26
|
# File 'lib/clusta/geometry/edge.rb', line 24
def labels_string
[source_label, target_label].map(&:to_s).join(' -> ')
end
|
#neighbor ⇒ Object
53
54
55
|
# File 'lib/clusta/geometry/edge.rb', line 53
def neighbor
Neighbor.new(target_label, weight)
end
|
#reversed ⇒ Object
49
50
51
|
# File 'lib/clusta/geometry/edge.rb', line 49
def reversed
self.class.new(target_label, source_label, weight)
end
|
#source_degree ⇒ Object
28
29
30
|
# File 'lib/clusta/geometry/edge.rb', line 28
def source_degree
Degree.new(source_label, 1)
end
|
#target_degree ⇒ Object
32
33
34
|
# File 'lib/clusta/geometry/edge.rb', line 32
def target_degree
Degree.new(target_label, 1)
end
|
#weighted? ⇒ Boolean
12
13
14
|
# File 'lib/clusta/geometry/edge.rb', line 12
def weighted?
self.weight
end
|