       for n2, j in nodes
         continue if n1 == n2
         outer = V n2.x, n2.y
-        sum = sum.add inner.sub outer
-
-      if sum.x isnt 0 or sum.y isnt 0
-        mag = sum.mag()
+        dif = inner.sub outer
+        mag = dif.mag()
         norm = 1.0 - Math.min(mag, MAX) / MAX
-        dir = sum.unit()
-        inner = inner.add dir.mult norm * 5
-        n1.x = inner.x
-        n1.y = inner.y
-
-      # .on('dblclick', (nodeClicked) ->
-      #   newNode = new Node
-      #   newNode.setParent nodeClicked
-      #   nodes.push newNode
-      #   update()
-      # )
+        dir = dif.unit()
+        sum = sum.add dir.mult norm * PUSH
+      inner = inner.add sum
+      n1.x = inner.x
+      n1.y = inner.y
 
   render = ->
-    # links
-    #   .attr('x1', (d) -> d.source.x)
-    #   .attr('y1', (d) -> d.source.y)
-    #   .attr('x2', (d) -> d.target.x)
-    #   .attr('y2', (d) -> d.target.y)
+    svg.selectAll('.link')
+      .attr('x1', (d) -> d.source.x + cx)
+      .attr('y1', (d) -> d.source.y + cy)
+      .attr('x2', (d) -> d.target.x + cx)
+      .attr('y2', (d) -> d.target.y + cy)
 
-    node
-      .attr('cx', (d) -> d.x)
-      .attr('cy', (d) -> d.y)
+    svg.selectAll('.node')
+      .attr('cx', (d) -> d.x + cx)
+      .attr('cy', (d) -> d.y + cy)
       .attr('r', 40)
-
 
   setInterval ->
     update()
-  , 1
+  , 10
 
   window.requestAnimationFrame = do ->
     window.requestAnimationFrame ||

$(document).ready ->

  class Node

    @ids = 0

    constructor: () ->
      @id = Node.ids++
      @x = 0
      @y = 0
      @parent = null
      @text = ''
      @children = []

    setParent: (parent) ->
      if @parent
        @parent.remove @
      @parent = parent
      @

    remove: (child) ->
      @children.splice @children.indexOf child, 1
      child

  randomColor = ->
    '#'+Math.floor(Math.random()*16777215).toString(16);

    render()
    requestAnimationFrame recursiveAnim
  )()


# rects = nodes
