code: function serialize(){
      var serialized = {
        nodes: nodes().map(function (id){
          return { id: id };
        }),
        links: []
      };
  
      serialized.nodes.forEach(function (node){
        var source = node.id;
        adjacent(source).forEach(function (target){
          serialized.links.push({
            source: source,
            target: target,
            weight: getEdgeWeight(source, target)
          });
        });
      });
  
      return serialized;
    }
docs: Serializes the graph.