Sets model.state to expose the serialized state.
function serializeState(){
      var data = model.data,
          scale = model.scale,
          translate = model.translate;
      model.state = {
        nodes: data.nodes.map(function(node){
          return {
            type: node.type,
            property: node.property,
            fixed: node.fixed,

            // Keep size of JSON small, so it fits in a URL.
            x: Math.round(node.x),
            y: Math.round(node.y)
          };
        }),
        links: data.links.map(function(link){
          // Replaced link object references with indices for serialization.
          return {
            source: link.source.index,
            target: link.target.index
          };
        }),
        scale: scale,
        translate: translate
      };
    }