class ChaosDetector::GraphTheory::Node

Constants

ROOT_NODE_NAME

Attributes

graph_props[W]
is_root[R]
node_origin[RW]
reduction[R]

Public Class Methods

new(name: nil, root: false, node_origin: nil, reduction: nil) click to toggle source
# File lib/chaos_detector/graph_theory/node.rb, line 18
def initialize(name: nil, root: false, node_origin: nil, reduction: nil)
  raise ArgumentError, "Must have name or be root (name=#{name})" unless ChaosUtils.aught?(name) || root

  @is_root = root
  @name = @is_root ? ROOT_NODE_NAME : name
  @node_origin = node_origin
  @reduction = reduction
  @graph_props = {}
end

Public Instance Methods

==(other) click to toggle source
# File lib/chaos_detector/graph_theory/node.rb, line 28
def ==(other)
  name == other.name &&
    is_root == other.is_root
end
graph_props() click to toggle source

Default behavior is accessor for @graph_props

# File lib/chaos_detector/graph_theory/node.rb, line 59
def graph_props
  @graph_props
end
merge!(other) click to toggle source

Mutate this Edge; combining attributes from other:

# File lib/chaos_detector/graph_theory/node.rb, line 64
def merge!(other)
  @reduction = ChaosDetector::GraphTheory::Reduction.combine(@reduction, other.reduction)
  self
end
name() click to toggle source
# File lib/chaos_detector/graph_theory/node.rb, line 42
def name
  @is_root ? ROOT_NODE_NAME : @name
end
root?() click to toggle source
# File lib/chaos_detector/graph_theory/node.rb, line 14
def root?
  !!is_root
end
subtitle() click to toggle source
# File lib/chaos_detector/graph_theory/node.rb, line 50
def subtitle
  nil
end
title() click to toggle source
# File lib/chaos_detector/graph_theory/node.rb, line 46
def title
  name
end
to_k() click to toggle source

Should be a reusable unique hash key for node:

# File lib/chaos_detector/graph_theory/node.rb, line 34
def to_k
  ChaosDetector::Utils::StrUtil.snakeize(name)
end
to_s(_scope=nil) click to toggle source
# File lib/chaos_detector/graph_theory/node.rb, line 38
def to_s(_scope=nil)
  name
end