Write the graph to a cache file.
189940
def writeCache(self, filename):
        """"""
        with open(filename, 'wb') as f:
            pickle.dump(self.modules, f)
194575
def write_ply(self, output_file):
        """"""
        points = np.hstack([self.coordinates, self.colors])
        with open(output_file, 'w') as outfile:
            outfile.write(self.ply_header.format(
                                            vertex_count=len(self.coordinates)))
            np.savetxt(outfile, points, '%f %f %f %d %d %d')
466002
def update(self, stats):
        """"""

        if self.generate_every != 0 and self._timer.finished():
            self.args.generate_graph = True
            self._timer.reset()

        if not self.args.generate_graph:
            return

        plugins = stats.getPluginsList()
        for plugin_name in plugins:
            plugin = stats._plugins[plugin_name]
            if plugin_name in self.plugins_to_export():
                self.export(plugin_name, plugin.get_export_history())

        logger.info("Graphs created in the folder {}".format(self.path))
        self.args.generate_graph = False
85613
public void write(Graph<? extends Edge> g, File gexfFile) 
            throws IOException {
        write(g, gexfFile, null);
    }
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)
1044968
public static <T> void write(final File file, final Graph<T> graph) throws IOException {
    final StringBuilder sb = new StringBuilder(String.format("strict graph {%n"));

    Set<Node<T>> doneNodes = new LinkedHashSet<>();
    for (Node<T> d : graph.nodes()) {
      for (Node<T> n : d.neighbours())
        if (!doneNodes.contains(n))
          sb.append("  ").append(d.content()).append(" -- ").append(n.content()).append(System.lineSeparator());
      doneNodes.add(d);
    }
    for (Node<T> d : graph.nodes()) {
      if (d.neighbours().isEmpty()) {
        sb.append("  ").append(d.content()).append(System.lineSeparator());
      }
    }
    sb.append("}");

    try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
      writer.append(sb);
      writer.flush();
    }
  }
1139266
def graph_draw(dir: '/tmp', format: 'svg'.freeze)
      graph_save do |dotfile|
        base = File.basename(dotfile.path)
        dest = File.join(dir, "#{base}.#{format}")
        system("dot -T#{format} #{dotfile.path} -o #{dest}")
        dest
      end
    end
680742
def _get_origcache(self, graph, dest, branch, turn, tick, *, forward):
        """"""
        origcache, origcache_lru, get_keycachelike, predecessors, adds_dels_sucpred = self._get_origcache_stuff
        lru_append(origcache, origcache_lru, ((graph, dest, branch), turn, tick), KEYCACHE_MAXSIZE)
        return get_keycachelike(
            origcache, predecessors, adds_dels_sucpred, (graph, dest),
            branch, turn, tick, forward=forward
        )
443326
def save_graph(cn_topo, filename, showintfs=False, showaddrs=False):
    '''
     
    '''
    __do_draw(cn_topo, showintfs=showintfs, showaddrs=showaddrs)
    pyp.savefig(filename)
984673
def write(self, buffer=bytes(), address=0, count=0):
        
        view = memoryview(self._cache)
        view[address:address + count] = buffer
1274040
def generate_graphs(data_frames, hardware_info, steps, outdir,
                    verbose=False):
    """"""
    _setup_matplotlib()
    # Hash of hosts containing (data, hardware, steps) tuple
    collectl_info = collections.defaultdict(dict)

    for host, data_frame in data_frames.items():
        if verbose:
            print('Generating CPU graph for {}...'.format(host))
        graph, data_cpu = graph_cpu(data_frame, steps, hardware_info[host]['num_cpus'])

        graph.get_figure().savefig(
            os.path.join(outdir, '{}_cpu.png'.format(host)),
            bbox_inches='tight', pad_inches=0.25)
        pylab.close()

        ifaces = set([series.split('_')[0]
                      for series in data_frame.keys()
                      if series.startswith(('eth', 'ib'))])

        if verbose:
            print('Generating network graphs for {}...'.format(host))
        graph, data_net_bytes = graph_net_bytes(data_frame, steps, ifaces)
        graph.get_figure().savefig(
            os.path.join(outdir, '{}_net_bytes.png'.format(host)),
            bbox_inches='tight', pad_inches=0.25)
        pylab.close()

        graph, data_net_pkts = graph_net_pkts(data_frame, steps, ifaces)
        graph.get_figure().savefig(
            os.path.join(outdir, '{}_net_pkts.png'.format(host)),
            bbox_inches='tight', pad_inches=0.25)
        pylab.close()

        if verbose:
            print('Generating memory graph for {}...'.format(host))
        graph, data_mem = graph_memory(data_frame, steps, hardware_info[host]["memory"])
        graph.get_figure().savefig(
            os.path.join(outdir, '{}_memory.png'.format(host)),
            bbox_inches='tight', pad_inches=0.25)
        pylab.close()

        if verbose:
            print('Generating storage I/O graph for {}...'.format(host))
        drives = set([
            series.split('_')[0]
            for series in data_frame.keys()
            if series.startswith(('sd', 'vd', 'hd', 'xvd'))
        ])
        graph, data_disk = graph_disk_io(data_frame, steps, drives)
        graph.get_figure().savefig(
            os.path.join(outdir, '{}_disk_io.png'.format(host)),
            bbox_inches='tight', pad_inches=0.25)
        pylab.close()

        print('Serializing output to pickle object for node {}...'.format(host))
        # "Clean" dataframes ready to be plotted
        collectl_info[host] = { "hardware": hardware_info,
                                "steps": steps, "cpu": data_cpu, "mem": data_mem,
                                "disk": data_disk, "net_bytes": data_net_bytes,
                                "net_pkts": data_net_pkts
                              }
    return collectl_info
903146
def _save_cache(self):
        """"""
        # Create the cache directory
        safe_makedirs(self.cache_dir)

        # Create/overwrite the cache file
        try:
            with open(self.cache_file, 'wb') as f:
                pickle.dump(self.data, f)
        except Exception as e:
            logger.error("Cannot write version to cache file {} ({})".format(self.cache_file, e))
744596
def output(self, filename):
        
        if filename == '':
            filename = 'contracts.dot'
        if not filename.endswith('.dot'):
            filename += ".dot"
        info = 'Inheritance Graph: ' + filename
        self.info(info)
        with open(filename, 'w', encoding='utf8') as f:
            f.write('digraph "" {\n')
            for c in self.contracts:
                f.write(self._summary(c))
            f.write('}')
746491
def dump(args):
    """"""
    if len(args) != 1:
        log.error('One target required.')
        app.quit(1)

    try:
        bb = Butcher()
        bb.load_graph(args[0])
    except error.BrokenGraph as lolno:
        log.fatal(lolno)
        app.quit(1)
    print "Nodes:"
    pprint.pprint(bb.graph.node)
    print "Edges:"
    pprint.pprint(bb.graph.edge)
728774
def write_dot(build_context, conf: Config, out_f):
    """"""
    not_buildenv_targets = get_not_buildenv_targets(build_context)
    prebuilt_targets = get_prebuilt_targets(build_context)
    out_f.write('strict digraph  {\n')
    for node in build_context.target_graph.nodes:
        if conf.show_buildenv_deps or node in not_buildenv_targets:
            cached = node in prebuilt_targets
            fillcolor = 'fillcolor="grey",style=filled' if cached else ''
            color = TARGETS_COLORS.get(
                build_context.targets[node].builder_name, 'black')
            out_f.write('  "{}" [color="{}",{}];\n'.format(node, color,
                                                           fillcolor))
    out_f.writelines('  "{}" -> "{}";\n'.format(u, v)
                     for u, v in build_context.target_graph.edges
                     if conf.show_buildenv_deps or
                     (u in not_buildenv_targets and v in not_buildenv_targets))
    out_f.write('}\n\n')
906196
def write(self, *messages):
        """"""

        for i in self.graph.outputs_of(BEGIN):
            for message in messages:
                self[i].write(message)
1001435
def write(graph, fileformat=None, filename=None):
        

        filewriter = None
        if fileformat is None:
            fileformat = 'turtle'
        if filename is not None:

            with open(filename, 'wb') as filewriter:
                LOG.info("Writing triples in %s to %s", fileformat, filename)
                # rdflib serialize
                graph.serialize(filewriter, format=fileformat)
        else:
            print(graph.serialize(fileformat).decode())
        return