         .call(force.drag)
 
     force.on 'tick', ->
+        for node in nodes
+            if node.children.length > 0
+                xMin = d3.min(node.children, (d) -> d.x - d.width / 2) - 5
+                xMax = d3.max(node.children, (d) -> d.x + d.width / 2) + 5
+                yMin = d3.min(node.children, (d) -> d.y - d.height / 2) - 5
+                yMax = d3.max(node.children, (d) -> d.y + d.height / 2) + 5
+                node.width = xMax - xMin
+                node.height = yMax - yMin
+                node.x = xMin + node.width / 2
+                node.y = yMin + node.height / 2
+
         q = d3.geom.quadtree(nodes)
 
         for i in [0 .. nodes.length - 1]

    nodeMap = {}

    for topState in tree
        walk topState, (state) ->
            node = {
                name: state.name
                radius: 20
            }
            nodes.push(node)
            nodeMap[state.name] = node

    r = 40



        svg.selectAll('.cell')
            .attr('transform', (node) -> "translate(#{node.x},#{node.y})")

        svg.selectAll('.cell rect')
            .attr('x', (node) -> - node.width / 2)
            .attr('y', (node) -> - node.height / 2)
            .attr('width', (node) -> node.width)
            .attr('height', (node) -> node.height)


collide = (node) ->
