Class: NoSE::Random::Network

Inherits:
Object
  • Object
show all
Defined in:
lib/nose/random.rb

Overview

A simple representation of a random ER diagram

Direct Known Subclasses

BarbasiAlbertNetwork, WattsStrogatzNetwork

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Network

Returns a new instance of Network.



11
12
13
14
15
# File 'lib/nose/random.rb', line 11

def initialize(params = {})
  @nodes_nb = params.fetch :nodes_nb, 10
  @field_count = RandomGaussian.new params.fetch(:num_fields, 3), 1
  @neighbours = Array.new(@nodes_nb) { Set.new }
end

Instance Attribute Details

#entitiesObject (readonly)

Returns the value of attribute entities.



9
10
11
# File 'lib/nose/random.rb', line 9

def entities
  @entities
end

Instance Method Details

#inspectObject

:nocov:



18
19
20
21
22
# File 'lib/nose/random.rb', line 18

def inspect
  @nodes.map do |node|
    @entities[node].inspect
  end.join "\n"
end