def save(self, filename, print_ir=False, format='dot'):
        """Save basic block graph into a file.
        """
        node_format = {
            'shape'    : 'Mrecord',
            'rankdir'  : 'LR',
            'fontname' : 'monospace',
            'fontsize' : '9.0',
        }

        edge_format = {
            'fontname' : 'monospace',
            'fontsize' : '8.0',
        }

        edge_colors = {
            'taken'     : 'green',
            'not-taken' : 'red',
            'direct'    : 'blue',
        }

        html_entities = {
            "!" : "&#33;",
            "#" : "&#35;",
            ":" : "&#58;",
            "{" : "&#123;",
            "}" : "&#125;",
        }

        try:
            dot_graph = Dot(graph_type="digraph", rankdir="TB")

            # Add nodes.
            nodes = {}
            for bb_addr in self._bb_by_addr:
                bb_dump = self._dump_bb(self._bb_by_addr[bb_addr], print_ir)

                # html-encode colon character
                for char, encoding in html_entities.items():
                    bb_dump = bb_dump.replace(char, encoding)

                label = "{{<f0> {:#08x} | {}}}".format(bb_addr, bb_dump)

                nodes[bb_addr] = Node(bb_addr, label=label, **node_format)

                dot_graph.add_node(nodes[bb_addr])

            # Add edges.
            for bb_src_addr in self._bb_by_addr:
                for bb_dst_addr, branch_type in self._bb_by_addr[bb_src_addr].branches:
                    # Skip jmp/jcc to sub routines.
                    if not self._bb_by_addr in bb_dst_addr:
                        continue

                    dot_graph.add_edge(
                        Edge(
                            nodes[bb_src_addr],
                            nodes[bb_dst_addr],
                            color=edge_colors[branch_type],
                            **edge_format))

            # Save graph.
            dot_graph.write("{}.{}".format(filename, format), format=format)
        except Exception:
            logger.error(
                "Failed to save basic block graph: %s (%s)",
                filename,
                format,
                exc_info=True
            )

    # Auxiliary functions
    # ======================================================================== #
dataset/ETHPy150Open programa-stic/barf-project/barf/barf/analysis/basicblock/basicblock.py/BasicBlockGraph.save/swapped operands of `in`