Class: ChaosDetector::GraphTheory::NodeMetrics
- Inherits:
- 
      Object
      
        - Object
- ChaosDetector::GraphTheory::NodeMetrics
 
- Extended by:
- Forwardable
- Defined in:
- lib/chaos_detector/graph_theory/node_metrics.rb
Constant Summary collapse
- GRAPH_PROPERTIES =
- %i[ total_couplings afference efference instability ].freeze 
Instance Attribute Summary collapse
- 
  
    
      #afference  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute afference. 
- 
  
    
      #circular_routes  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute circular_routes. 
- 
  
    
      #efference  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute efference. 
- 
  
    
      #node  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute node. 
- 
  
    
      #terminal_routes  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute terminal_routes. 
Instance Method Summary collapse
- 
  
    
      #initialize(node, afference: 0, efference: 0, terminal_routes:, circular_routes:)  ⇒ NodeMetrics 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of NodeMetrics. 
- 
  
    
      #instability  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    en.wikipedia.org/wiki/Software_package_metrics I = Ce / (Ce + Ca). 
- #reduction_count ⇒ Object
- #reduction_sum ⇒ Object
- #summary ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
- #total_couplings ⇒ Object
Constructor Details
#initialize(node, afference: 0, efference: 0, terminal_routes:, circular_routes:) ⇒ NodeMetrics
Returns a new instance of NodeMetrics.
| 25 26 27 28 29 30 31 32 33 | # File 'lib/chaos_detector/graph_theory/node_metrics.rb', line 25 def initialize(node, afference: 0, efference: 0, terminal_routes:, circular_routes:) raise ArgumentError("node is required") if node.nil? @node = node @afference = afference @efference = efference @terminal_routes = terminal_routes || [] @circular_routes = circular_routes || [] end | 
Instance Attribute Details
#afference ⇒ Object
Returns the value of attribute afference.
| 9 10 11 | # File 'lib/chaos_detector/graph_theory/node_metrics.rb', line 9 def afference @afference end | 
#circular_routes ⇒ Object
Returns the value of attribute circular_routes.
| 12 13 14 | # File 'lib/chaos_detector/graph_theory/node_metrics.rb', line 12 def circular_routes @circular_routes end | 
#efference ⇒ Object
Returns the value of attribute efference.
| 10 11 12 | # File 'lib/chaos_detector/graph_theory/node_metrics.rb', line 10 def efference @efference end | 
#node ⇒ Object (readonly)
Returns the value of attribute node.
| 13 14 15 | # File 'lib/chaos_detector/graph_theory/node_metrics.rb', line 13 def node @node end | 
#terminal_routes ⇒ Object
Returns the value of attribute terminal_routes.
| 11 12 13 | # File 'lib/chaos_detector/graph_theory/node_metrics.rb', line 11 def terminal_routes @terminal_routes end | 
Instance Method Details
#instability ⇒ Object
en.wikipedia.org/wiki/Software_package_metrics I = Ce / (Ce + Ca). I = efference / (total couplings) Value from 0.0 to 1.0 I = 0.0 is maximally stable while I = 1.0 is maximally unstable.
| 41 42 43 44 | # File 'lib/chaos_detector/graph_theory/node_metrics.rb', line 41 def instability cT = total_couplings.to_f (cT.zero?) ? 0.0 : @efference / cT end | 
#reduction_count ⇒ Object
| 21 22 23 | # File 'lib/chaos_detector/graph_theory/node_metrics.rb', line 21 def reduction_count @node&.reduction&.reduction_count || 1 end | 
#reduction_sum ⇒ Object
| 17 18 19 | # File 'lib/chaos_detector/graph_theory/node_metrics.rb', line 17 def reduction_sum @node&.reduction&.reduction_sum || 1 end | 
#summary ⇒ Object
| 50 51 52 | # File 'lib/chaos_detector/graph_theory/node_metrics.rb', line 50 def summary 'I = Ce / (Ce + Ca)' end | 
#to_h ⇒ Object
| 54 55 56 57 58 59 60 61 | # File 'lib/chaos_detector/graph_theory/node_metrics.rb', line 54 def to_h { afference: afference, efference: efference, instability: instability.round(2), total_couplings: total_couplings } end | 
#to_s ⇒ Object
| 63 64 65 | # File 'lib/chaos_detector/graph_theory/node_metrics.rb', line 63 def to_s "Ce: #{@efference}, Ca: #{@afference}, I: #{instability}" end | 
#total_couplings ⇒ Object
| 46 47 48 | # File 'lib/chaos_detector/graph_theory/node_metrics.rb', line 46 def total_couplings @afference + @efference end |