Module: Clusta::Geometry

Defined in:
lib/clusta/geometry.rb,
lib/clusta/geometry/edge.rb,
lib/clusta/geometry/degree.rb,
lib/clusta/geometry/vertex.rb,
lib/clusta/geometry/element.rb,
lib/clusta/geometry/neighbor.rb,
lib/clusta/geometry/degree_pair.rb,
lib/clusta/geometry/neighborhood.rb,
lib/clusta/geometry/assortativity.rb,
lib/clusta/geometry/directed/edge.rb,
lib/clusta/geometry/directed/degree.rb,
lib/clusta/geometry/directed/neighbor.rb,
lib/clusta/geometry/directed/degree_pair.rb,
lib/clusta/geometry/directed/neighborhood.rb

Defined Under Namespace

Classes: Assortativity, Degree, DegreePair, DirectedDegree, DirectedDegreePair, DirectedEdge, DirectedNeighbor, DirectedNeighborhood, Edge, Element, Neighbor, Neighborhood, Vertex

Class Method Summary collapse

Class Method Details

.from_name(name) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/clusta/geometry.rb', line 19

def self.from_name name
  begin
    const_get(Clusta.classify(name))
  rescue NameError => e
    raise Error.new("No such transform: '#{name}'")
  end
end

.listingObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/clusta/geometry.rb', line 40

def self.listing
  [].tap do |out|
    out << "Known geometries:"
    out << ''
    names.keys.sort.each do |element_name|
      element = from_name(element_name)
      if names[element_name][:directed]
        directed_element = from_name("directed_#{element_name}")
      else
        directed_element = nil
      end
      
      out << "  #{element}"
      stream_names = element.all_stream_names.sort
      stream_names.concat(directed_element.all_stream_names.sort) if directed_element
      out << "    streams as: #{stream_names.uniq.join(', ')}"
      out << ''
    end
  end.join("\n")
end

.load_from(path) ⇒ Object



61
62
63
64
65
66
# File 'lib/clusta/geometry.rb', line 61

def self.load_from path
  class_eval(File.read(path), path)
  require_name = Clusta.require_name(path)
  names[require_name] ||= {}
  names[require_name][:directed] = true if require_name =~ /^directed_/
end

.namesObject



5
6
7
# File 'lib/clusta/geometry.rb', line 5

def self.names
  @names ||= {}
end

.register_element(klass, name = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/clusta/geometry.rb', line 9

def self.register_element klass, name=nil
  if name
    Wukong::RESOURCE_CLASS_MAP[name] = klass
  else
    klass.all_stream_names.each do |name|
      Wukong::RESOURCE_CLASS_MAP[name] = klass
    end
  end
end