Serializes the graph.
194941
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;
  }
66945
def _write_to_graph(self):
        """"""
        traces = []
        for byte_code, trace_data in self.coverage.items():
            traces += [list(trace_data.keys()), list(trace_data.values()), "r--"]

        plt.plot(*traces)
        plt.axis([0, self.end - self.begin, 0, 100])
        plt.xlabel("Duration (seconds)")
        plt.ylabel("Coverage (percentage)")

        plt.savefig("{}.png".format(self.name))
142136
public final void serialize(OutputStream out) throws IOException {
        out.write(Jackson.toJsonString(this).getBytes(UTF8));
        out.flush();
    }
1078841
private static void serialize(Map<String, AbstractDataMarshaller<?>> marshallerMap,
            DataOutputStream dOut, DataNode primaryNode, boolean ignoreMissingMarshallers,
            ProgressListener progressListener) throws IOException {

        //a map containing all serialized objects. This is used
        //to make sure that we store each deSerializedObject only once.
        final Map<SerializedObject, SerializedObject> serializedObjects = new HashMap<>();

        final Deque<SerializationFrame> stack = new LinkedList<>();
        final DataNodeSerializationFrame primaryDataNodeFrame = new DataNodeSerializationFrame(null, primaryNode);

        progressListener.onTotalSteps(primaryDataNodeFrame.entries.size());
        stack.add(primaryDataNodeFrame);


        final SerializedObject testSerializedObject = new SerializedObject();

        while (!stack.isEmpty()) {
            final SerializationFrame frame = stack.peek();

            //writes the header for that frame (if needed)
            frame.writeHeader(dOut);

            if (frame.hasNext()) {
                while (frame.hasNext()) {
                    if (frame.next(stack, dOut, marshallerMap,
                            serializedObjects, testSerializedObject,
                            ignoreMissingMarshallers)) {
                        if (frame == primaryDataNodeFrame) {
                            progressListener.onStep();
                        }
                        break;
                    }
                    if (frame == primaryDataNodeFrame) {
                        progressListener.onStep();
                    }
                }
            } else {
                stack.pop();

                //remember serialized deSerializedObject's addresses
                if (frame instanceof DataNodeSerializationFrame) {
                    DataNodeSerializationFrame dataNodeFrame = (DataNodeSerializationFrame) frame;
                    SerializedObject newSerializedObject = new SerializedObject();
                    newSerializedObject.object = frame.object;
                    newSerializedObject.positionInStream = dataNodeFrame.positionInStream;
                    serializedObjects.put(newSerializedObject, newSerializedObject);
                }
            }
        }
    }
1239873
public void serialize(final DataOutput pOutput) throws TTIOException {
        try {
            pOutput.writeInt(getRawValue().length);
            pOutput.write(getRawValue());
        } catch (final IOException exc) {
            throw new TTIOException(exc);
        }
    }
1350850
def save_graph(graphdef):
    ''''''
    if graphdef.filename is None:
        if 'HOME' in os.environ:
            dname = os.path.join(os.environ['HOME'], '.mavproxy')
            if os.path.exists(dname):
                mp_util.mkdir_p(dname)
                graphdef.filename = os.path.join(dname, 'mavgraphs.xml')
        elif 'LOCALAPPDATA' in os.environ:
            dname = os.path.join(os.environ['LOCALAPPDATA'], 'MAVProxy')
            if os.path.exists(dname):
                mp_util.mkdir_p(dname)
                graphdef.filename = os.path.join(dname, 'mavgraphs.xml')
        else:
            graphdef.filename = 'mavgraphs.xml'
    if graphdef.filename is None:
        print("No file to save graph to")
        return
    try:
        graphs = load_graph_xml(open(graphdef.filename).read(), graphdef.filename, load_all=True)
    except Exception:
        graphs = []
    found_name = False
    for i in range(len(graphs)):
        if graphs[i].name == graphdef.name:
            graphs[i] = graphdef
            found_name = True
            break
    if not found_name:
        graphs.append(graphdef)
    pipe_console_input.send("Saving %u graphs to %s" % (len(graphs), graphdef.filename))
    f = open(graphdef.filename, "w")
    f.write("<graphs>\n\n")
    for g in graphs:
        f.write(" <graph name='%s'>\n" % g.name.strip())
        if g.description is None:
            g.description = ''
        f.write("  <description>%s</description>\n" % g.description.strip())
        for e in g.expressions:
            f.write("  <expression>%s</expression>\n" % e.strip())
        f.write(" </graph>\n\n")
    f.write("</graphs>\n")
    f.close()
686736
def serialize(self):
        '''
        
        '''
        serialized = {'type': self.__type__}
        for argname in self._attributes:
            if argname == 'required':
                # This is handled elsewhere
                continue
            argvalue = self._get_argname_value(argname)
            if argvalue is not None:
                if argvalue is Null:
                    argvalue = None
                # None values are not meant to be included in the
                # serialization, since this is not None...
                if self.__serialize_attr_aliases__ and argname in self.__serialize_attr_aliases__:
                    argname = self.__serialize_attr_aliases__[argname]
                serialized[argname] = argvalue
        return serialized
415954
public static void saveGraph(DirectedGraph<Integer, DefaultEdge> graph, String location) throws IOException {
		File file = new File(location);
		file.createNewFile();
		if (!file.canWrite()) {
			throw new IOException("Cannot write to file " + location);
		}
		GraphSerialization.saveGraph(graph, file);
	}
764038
def assemble_graph():
    """"""
    if request.method == 'OPTIONS':
        return {}
    response = request.body.read().decode('utf-8')
    body = json.loads(response)
    stmts_json = body.get('statements')
    stmts = stmts_from_json(stmts_json)
    ga = GraphAssembler(stmts)
    model_str = ga.make_model()
    res = {'model': model_str}
    return res
1176135
@Override
    public void marshalWriter(Object graph, Writer writer, DataHolder dataHolder) throws XmlMappingException,
            IOException {
        if (graph instanceof Document) {
            OutputFormat outputFormat = OutputFormat.createCompactFormat();
            outputFormat.setSuppressDeclaration(suppressXmlDeclaration);

            XMLWriter xmlWriter = new XMLWriter(writer, outputFormat);
            try {
                xmlWriter.write((Document)graph);
            } finally {
                try {
                    xmlWriter.flush();
                } catch (Exception ex) {
                    logger.debug("Could not flush XMLWriter", ex);
                }
            }
        } else {
            if (!suppressXmlDeclaration) {
                writer.write(XML_DECLARATION);
            }

            HierarchicalStreamWriter streamWriter = new EscapingCompactWriter(writer);
            try {
                getXStream().marshal(graph, streamWriter, dataHolder);
            } catch (Exception ex) {
                throw convertXStreamException(ex, true);
            } finally {
                try {
                    streamWriter.flush();
                } catch (Exception ex) {
                    logger.debug("Could not flush HierarchicalStreamWriter", ex);
                }
            }
        }
    }
906196
def write(self, *messages):
        """"""

        for i in self.graph.outputs_of(BEGIN):
            for message in messages:
                self[i].write(message)
120704
def to_json_file(graph: BELGraph, file: TextIO, **kwargs) -> None:
    """"""
    graph_json_dict = to_json(graph)
    json.dump(graph_json_dict, file, ensure_ascii=False, **kwargs)
706729
def save(self):
        
        if self.parent.buffered:
            query = """
                INSERT DATA { GRAPH %s { %s } }
            """
            query = query % (self.identifier.n3(),
                             self.graph.serialize(format='nt'))
            self.parent.graph.update(query)
            self.flush()
        else:
            self.meta.generate()
1190558
def serialize(self, format="turtle"):
        
        if self.triples:
            if not self.rdfgraph:
                self._buildGraph()
            return self.rdfgraph.serialize(format=format)
        else:
            return None
269048
def _serialize_lnk(lnk):
    """"""
    s = ""
    if lnk is not None:
        s = '<'
        if lnk.type == Lnk.CHARSPAN:
            cfrom, cto = lnk.data
            s += ''.join([str(cfrom), ':', str(cto)])
        elif lnk.type == Lnk.CHARTSPAN:
            cfrom, cto = lnk.data
            s += ''.join([str(cfrom), '#', str(cto)])
        elif lnk.type == Lnk.TOKENS:
            s += ' '.join([str(t) for t in lnk.data])
        elif lnk.type == Lnk.EDGE:
            s += ''.join(['@', str(lnk.data)])
        s += '>'
    return s
1020679
def serialize(self):
        
        df = self.copy()
        df['scored_calls'] = df['scored_calls'].apply(lambda x: json.dumps(x))
        df['channel_values'] = df['channel_values'].apply(lambda x: json.dumps(x))
        df['regions'] = df['regions'].apply(lambda x: json.dumps(x))
        df['phenotype_calls'] = df['phenotype_calls'].apply(lambda x: json.dumps(x))
        df['neighbors'] = df['neighbors'].apply(lambda x: json.dumps(x))
        df['frame_shape'] = df['frame_shape'].apply(lambda x: json.dumps(x))
        return df
308524
static void serialize(DataOutput out, Serializers serializers)
      throws IOException {
    StringBuilder msg = new StringBuilder(String.format("Serialize %d serializer classes:", serializers.serializers.values().size()));
    int size = serializers.serializers.values().size();

    out.writeInt(size);
    if (size > 0) {
      for (SerializerWrapper sw : serializers.serializers.values()) {
        int index = sw.index;
        String name = sw.serializer.getClass().getName();

        out.writeInt(index);
        out.writeUTF(name);

        msg.append(String.format("%n  (%d) %s", index, name));
      }
      LOGGER.info(msg.toString());
    }
  }