Saves the current graph representation into a file
169181
def save_dot(self, file_name=None):
        '''
        
        '''

        if not file_name:
            warnings.warn(DeprecationWarning, "always pass a file_name")
            file_name = self.temp_dot

        fp   = open(file_name, "w")
        try:
            for chunk in self.iterdot():
                fp.write(chunk)
        finally:
            fp.close()
430872
def _build_graph(self):
        
        self._graph.add_nodes_from(self.tasks)
        for node1 in self._graph.nodes:
            for node2 in self._graph.nodes:
                for input_file in node1.inputs:
                    for output_file in node2.outputs:
                        if output_file == input_file:
                            self._graph.add_edge(node2, node1)
        for order, task in enumerate(topological_sort(self._graph)):
            task.predecessors = self._graph.predecessors(task)
            task.order = order
262514
def dumps(graphs, triples=False, cls=PENMANCodec, **kwargs):
    
    codec = cls(**kwargs)
    strings = [codec.encode(g, triples=triples) for g in graphs]
    return '\n\n'.join(strings)
641381
def dump_nt_sorted(g: Graph) -> List[str]:
    
    return [l.decode('ascii') for l in sorted(g.serialize(format='nt').splitlines()) if l]
519128
def write_graphml(docgraph, output_file):
    
    dg_copy = deepcopy(docgraph)
    layerset2str(dg_copy)
    attriblist2str(dg_copy)
    remove_root_metadata(dg_copy)
    nx_write_graphml(dg_copy, output_file)
443823
def render_output_json(self, graph_data, output_file=None):
        """"""
        if output_file:
            with open(output_file, 'wt') as json_output_f:
                json.dump(graph_data, json_output_f)
        else:
            self.stdout.write(json.dumps(graph_data))
1173617
def edges_dump(self):
        """"""
        self._flush_edges()
        for (
                graph, orig, dest, idx, branch, turn, tick, extant
        ) in self.sql('edges_dump'):
            yield (
                self.unpack(graph),
                self.unpack(orig),
                self.unpack(dest),
                idx,
                branch,
                turn,
                tick,
                bool(extant)
            )
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))
628525
def graph_save(permanent: false, &block)
      if block
        Tempfile.open{|tmp|
          graph(output: tmp)
          tmp.seek(0)
          block.(tmp)
        }
      else
        tmp = Tempfile.open
        graph(output: tmp).tap{|t|t.seek(0)}
      end
    end
616738
function saveGraphSONSync(graph, filename) {
        var FileOutputStream = Tinkerpop.autoImport('FileOutputStream');
        var stream = new FileOutputStream(filename);
        var builder = Tinkerpop.GraphSONWriter.build();
        var mapper = _newGraphSONMapperSync();
        builder.mapper(mapper);
        var writer = builder.create();
        writer.writeGraph(stream, graph);
        return graph;
    }
770865
def to_string(self):
        

        src = self.parse_node_ref( self.get_source() )
        dst = self.parse_node_ref( self.get_destination() )
        
        if isinstance(src, frozendict):
            edge = [ Subgraph(obj_dict=src).to_string() ]
        elif isinstance(src, (int, long)):
            edge = [ str(src) ]
        else:
            edge = [ src ]
        
        if	(self.get_parent_graph() and
            self.get_parent_graph().get_top_graph_type() and
            self.get_parent_graph().get_top_graph_type() == 'digraph' ):

            edge.append( '->' )
            
        else:
            edge.append( '--' )
            
        if isinstance(dst, frozendict):
            edge.append( Subgraph(obj_dict=dst).to_string() )
        elif isinstance(dst, (int, long)):
            edge.append( str(dst) )
        else:
            edge.append( dst )


        edge_attr = list()
        
        for attr, value in self.obj_dict['attributes'].iteritems():
        
            if value is not None:
                edge_attr.append( '%s=%s' % (attr, quote_if_necessary(value) ) )
            else:
                edge_attr.append( attr )

        edge_attr = ', '.join(edge_attr)
        
        if edge_attr:
            edge.append( ' [' + edge_attr + ']' )

        return ' '.join(edge) + ';'
114162
def dump_tf_graph(tfgraph, tfgraphdef):
    
    print("Nodes ({})".format(len(tfgraphdef.node)))
    f = "{:15} {:59} {:20} {}"
    print(f.format("kind", "scopeName", "shape", "inputs"))
    for node in tfgraphdef.node:
        scopename = node.name
        kind = node.op
        inputs = node.input
        shape = tf.graph_util.tensor_shape_from_node_def_name(tfgraph, scopename)
        print(f.format(kind, scopename, str(shape), inputs))
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)
940478
def save_model(self, steps):
        
        with self.graph.as_default():
            last_checkpoint = self.model_path + '/model-' + str(steps) + '.cptk'
            self.saver.save(self.sess, last_checkpoint)
            tf.train.write_graph(self.graph, self.model_path,
                                 'raw_graph_def.pb', as_text=False)
851409
def dbg_draw(self, filename):
        
        import matplotlib.pyplot as pyplot  # pylint: disable=import-error
        from networkx.drawing.nx_agraph import graphviz_layout  # pylint: disable=import-error

        tmp_graph = networkx.DiGraph()
        for from_block, to_block in self.transition_graph.edges():
            node_a = "%#08x" % from_block.addr
            node_b = "%#08x" % to_block.addr
            if node_b in self._ret_sites:
                node_b += "[Ret]"
            if node_a in self._call_sites:
                node_a += "[Call]"
            tmp_graph.add_edge(node_a, node_b)
        pos = graphviz_layout(tmp_graph, prog='fdp')   # pylint: disable=no-member
        networkx.draw(tmp_graph, pos, node_size=1200)
        pyplot.savefig(filename)
144292
def export_obj(vertices, triangles, filename):
    
    
    with open(filename, 'w') as fh:
        
        for v in vertices:
            fh.write("v {} {} {}\n".format(*v))
            
        for f in triangles:
            fh.write("f {} {} {}\n".format(*(f + 1)))
758942
def graph_from_dot_file(path):
    

    fd = open(path, 'rb')
    data = fd.read()
    fd.close()

    return graph_from_dot_data(data)