title: Non-hierarchical (without gaps between groups) bundle layout in D3
body: <p>I'm trying to make a bundle layout with D3. However, I'd like to make it non-hierarchical (or pseudo non-hierarchical) so as to have no gaps between the edge nodes. The image below hopefully serves as a good example of the gaps I would like to remove (see top of image between different coloured text).</p>
  
  <p><img src="https://i.stack.imgur.com/8tbV1.png" alt="Bundle chart"></p>
  
  <p>I've attempted to remedy this two ways: by replacing the type which distinguishes node types with a generic type, and by replacing the node type with the authors' names (thereby making all nodes a different type, forcing equal spacing). The former of these attempts being similar to the suggestion proposed in response to <a href="https://stackoverflow.com/questions/10787236/bundle-layout-using-d3-js">this</a> query.</p>
  
  <p>However, when I run the line</p>
  
  <pre><code> var nodes = cluster.nodes(packageHierarchy(theArr, id_to_user_dict)); 
  </code></pre>
  
  <p>I inevitably get the error "Uncaught TypeError: Cannot read property 'parent' of undefined." How can I force a generic root on this data so that my code works properly?</p>
  
  <p>My code to generate the code structure for the included diagram is below. The two solutions that I proposed above are commented out within the "package hierarchy" function. Note that it is derived from <a href="http://bl.ocks.org/mbostock/7607999" rel="nofollow noreferrer">Bostock's sample for hierarchical edge bundling</a>.</p>
  
  <pre><code>function packageHierarchy(classes, dictionary) {
  for (var i = 0; i &lt; classes.length; i++){
      var imports = [];
      // classes[i].name = "root" + "^" + classes[i]["author"];
      // classes[i].name = classes[i]["author"] + "^" + classes[i]["author"];
      classes[i].name = classes[i]["type"] + "^" + classes[i]["author"];
      for (var j = 0; j &lt; classes[i]["values"].length; j++){
          if (classes[i]["values"][j]["type"] == "comments"){
              var responseObj = classes[i]["values"][j]["in_response_to"];
              var responseAuthor = dictionary[classes[i]["values"][j]["in_response_to"]];
              if (responseAuthor != undefined){
                  imports.push(responseAuthor);
              }
          }
      }
      classes[i].imports = imports;
  
  }
  
  
  var map = {};
  
  function find(name, data) {
      var node = map[name], i;
      if (!node) {
          node = map[name] = data || {name: name, children: [] };
          if (name.length) {
                  node.parent = find(name.substring(0, i = name.indexOf("^")));
                  node.parent.children.push(node);
                  node.key = name.substring(i + 1);
          }
      }
      return node;
  }
  
  classes.forEach(function(d) {
      find(d.name, d);
  });
  
  return map[""];
  }
  </code></pre>