code: function(kgraph) {
          if (kgraph) {
            zoomToFit(kgraph);
            // assign coordinates to nodes
            kgraph.children.forEach(function(n) {
              var d3node = nodes[parseInt(n.id)];
              copyProps(n, d3node);
              (n.ports || []).forEach(function(p, i) {
                copyProps(p, d3node.ports[i]);
              });
              (n.labels || []).forEach(function(l, i) {
                copyProps(l, d3node.labels[i]);
              });
            });
            // edges
            kgraph.edges.forEach(function(e) {
              var l = links[parseInt(e.id) - nodes.length];
              copyProps(e, l);
              copyProps(e.source, l.source);
    	        copyProps(e.target, l.target);
              // make sure the bendpoint array is valid
              l.bendPoints = e.bendPoints || [];
            });
          }
          function copyProps(src, tgt, copyKeys) {
            var keys = kgraphKeys;
            if (copyKeys) {
              keys = copyKeys.reduce(function (p, c) {p[c] = 1; return p;}, {});
            }
            for (var k in src) {
              if (keys[k]) {
                tgt[k] = src[k];
              }
            }
          }
          // invoke the 'finish' event
          dispatch.finish({graph: kgraph});
        }
docs: Apply layout for d3 style.
  Copies properties of the layouted graph
  back to the original nodes and links.