         mag = dif.mag()
         norm = 1.0 - Math.min(mag, MAX) / MAX
         dir = dif.unit()
-        sum = sum.add dir.mult norm * PUSH
+        if (not isNaN dir.x) and (not isNaN dir.y)
+          sum = sum.add dir.mult norm * PUSH
       inner = inner.add sum
       n1.x = inner.x
       n1.y = inner.y
 
+    # for n1, i in nodes
+    #   inner = V n1.x, n1.y
+    #   if n1.parent isnt null
+    #     parent = nodes[n1.parent]
+    #     outer = V parent.x, parent.y
+    #     dif = outer.sub inner
+    #     mag = dif.mag()
+    #     if mag > MAX
+    #       n1.locked = true
+    #       setTimeout ->
+    #         n1.locked = false
+    #       , 1000
+
   render = ->
     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)
+      .attr('x1', (d) -> nodes[d.source].x + cx)
+      .attr('y1', (d) -> nodes[d.source].y + cy)
+      .attr('x2', (d) -> nodes[d.target].x + cx)
+      .attr('y2', (d) -> nodes[d.target].y + cy)
 
     svg.selectAll('.node')
-      .attr('cx', (d) -> d.x + cx)
-      .attr('cy', (d) -> d.y + cy)
-      .attr('r', 40)
+      .attr('transform', (d) -> "translate(#{d.x + cx},#{d.y + cy})")
+
+    svg.selectAll('.node circle')
+      .attr('cx', 0)
+      .attr('cy', 0)
+      .attr('r', 30)
+
+    svg.selectAll('.node text')
+      .text((d) -> d.text)
+      .attr('x', 0)
+      .attr('y', 0)
+      .attr('fill', 'red')
+      .attr('font-size', '20px')
 
   setInterval ->
     update()

        .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
      inner = V n1.x, n1.y
      for n2, j in nodes

      cx += dx
      cy += dy

  if nodes.length is 0
    head = new Node()
    head.x = w / 2
    head.y = h / 2

  circles = null
  rects = null
  texts = null

  refresh = ->
    svg.selectAll('.link')
