Class: NoSE::Random::WattsStrogatzNetwork

Inherits:
Network show all
Defined in:
lib/nose/random/watts_strogatz.rb

Overview

Generates a random graph using the Watts-Strogatz model

Instance Attribute Summary

Attributes inherited from Network

#entities

Instance Method Summary collapse

Methods inherited from Network

#inspect

Constructor Details

#initialize(params = {}) ⇒ WattsStrogatzNetwork

Returns a new instance of WattsStrogatzNetwork.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/nose/random/watts_strogatz.rb', line 7

def initialize(params = {})
  super params

  @beta = params.fetch :beta, 0.5
  @node_degree = params.fetch :node_degree, 2
  @nodes = 0..(@nodes_nb - 1)

  @entities = @nodes.map do |node|
    create_entity node
  end

  build_initial_links
  rewire_links
  add_foreign_keys
end