Class: Graphomaton::Layout::ForceTree

Inherits:
Object
  • Object
show all
Defined in:
lib/graphomaton/layout/force_tree.rb

Defined Under Namespace

Classes: Node

Constant Summary collapse

DEFAULT_THETA =
0.6
LEAF_CAPACITY =
4
MAX_DEPTH =
20

Instance Method Summary collapse

Constructor Details

#initialize(positions) ⇒ ForceTree

Returns a new instance of ForceTree.



15
16
17
18
# File 'lib/graphomaton/layout/force_tree.rb', line 15

def initialize(positions)
  @root = build_root(positions)
  positions.each { |name, position| insert(@root, name, position, 0) }
end

Instance Method Details

#force_on(name, position, coefficient, theta: DEFAULT_THETA, &coincident_delta) ⇒ Object



20
21
22
# File 'lib/graphomaton/layout/force_tree.rb', line 20

def force_on(name, position, coefficient, theta: DEFAULT_THETA, &coincident_delta)
  force_from_node(@root, name, position, coefficient.to_f, theta.to_f, coincident_delta)
end