     render()
     requestAnimationFrame recursiveAnim
   )()
-
 
 
 # rects = nodes

      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()
        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()
      # )

  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)

    node
      .attr('cx', (d) -> d.x)
      .attr('cy', (d) -> d.y)
      .attr('r', 40)


  setInterval ->
    update()
  , 1

  window.requestAnimationFrame = do ->
    window.requestAnimationFrame ||

    svg.attr 'width', w
    svg.attr 'height', h

  $(window).on 'mousedown', (e) ->
    sx = e.clientX
    sy = e.clientY

  $(window).on 'mouseup', (e) ->
    sx = null
    sy = null

  $(window).on 'mousemove', (e) ->
    if sx? and sy?
      dx = e.clientX - sx
      dy = e.clientY - sy
      sx = e.clientX
      sy = e.clientY
      cx += dx
      cy += dy

  head = new Node()
  head.x = w / 2
  head.y = h / 2

  link = null
  node = null

  circles = null
  rects = null
  texts = null

  new Node().setParent head
  new Node().setParent head
  new Node().setParent head
  new Node().setParent head
  new Node().setParent head
  new Node().setParent head
  new Node().setParent head

  refresh = ->
    svg.selectAll('.link')
      .data(links, (d) -> d.id)
      .enter()
        .insert('line', ':first-child')
        .classed('link', true)

    svg.selectAll('.node')
      .data(nodes, (d) -> d.id)
      .enter()
        .append('circle')
        .classed('node', true)
        .on('dblclick', (nodeClicked) ->
          new Node().setParent nodeClicked
          refresh()
        )
  refresh()

  update = ->
    MAX = 200
    PUSH = 5

    for n1, i in nodes
      sum = V 0, 0
