Class: Clusta::Geometry::Neighborhood

Inherits:
Vertex show all
Defined in:
lib/clusta/geometry/neighborhood.rb

Direct Known Subclasses

DirectedNeighborhood

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_pairsObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/clusta/geometry/neighborhood.rb', line 20

def degree_pairs
  neighbors.map do |neighbor|
    # This vertex's degree is just the size of this
    # neighborhood.
    # 
    # We don't know anything about each neighbor's degree other
    # than it must be at least 1 b/c it's in this vertex's
    # neighborhood.
    DegreePair.new(label, neighbor.label, size, 1)
  end
end

#directed?Boolean

Returns:

  • (Boolean)


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

def directed?
  false
end

#joins?(label) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/clusta/geometry/neighborhood.rb', line 8

def joins? label
  neighbors.detect { |neighbor| neighbor.label == label }
end

#reversed_degree_pairsObject



32
33
34
35
36
# File 'lib/clusta/geometry/neighborhood.rb', line 32

def reversed_degree_pairs
  neighbors.map do |neighbor|
    DegreePair.new(neighbor.label, label, 1, size)
  end
end

#sizeObject



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

def size
  neighbors.size
end