class ChaosDetector::GraphTheory::NodeMetrics
Constants
- GRAPH_PROPERTIES
Attributes
afference[RW]
circular_routes[RW]
efference[RW]
node[R]
terminal_routes[RW]
Public Class Methods
new(node, afference: 0, efference: 0, terminal_routes:, circular_routes:)
click to toggle source
# 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
Public Instance Methods
instability()
click to toggle source
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.
# 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()
click to toggle source
# File lib/chaos_detector/graph_theory/node_metrics.rb, line 21 def reduction_count @node&.reduction&.reduction_count || 1 end
reduction_sum()
click to toggle source
# File lib/chaos_detector/graph_theory/node_metrics.rb, line 17 def reduction_sum @node&.reduction&.reduction_sum || 1 end
summary()
click to toggle source
# File lib/chaos_detector/graph_theory/node_metrics.rb, line 50 def summary 'I = Ce / (Ce + Ca)' end
to_h()
click to toggle source
# 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()
click to toggle source
# File lib/chaos_detector/graph_theory/node_metrics.rb, line 63 def to_s "Ce: #{@efference}, Ca: #{@afference}, I: #{instability}" end
total_couplings()
click to toggle source
# File lib/chaos_detector/graph_theory/node_metrics.rb, line 46 def total_couplings @afference + @efference end