def write_dot(g):
lines = ["<STR_LIT>"]<EOL>def attrs_txt(items):<EOL><INDENT>if items:<EOL><INDENT>txt = "<STR_LIT:U+002CU+0020>".join(('<STR_LIT>' % (k, str(v).strip('<STR_LIT:">')))<EOL>for k, v in items)<EOL>return '<STR_LIT:[>' + txt + '<STR_LIT:]>'<EOL><DEDENT>else:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT><DEDENT>for node in g.nodes():<EOL><INDENT>atxt = attrs_txt(g.node_attributes(node))<EOL>txt = "<STR_LIT>" % (node, atxt)<EOL>lines.append(txt)<EOL><DEDENT>for e in g.edges():<EOL><INDENT>edge_from, edge_to = e<EOL>attrs = g.edge_attributes(e)<EOL>label = str(g.edge_label(e))<EOL>if label:<EOL><INDENT>attrs.append(("<STR_LIT:label>", label))<EOL><DEDENT>atxt = attrs_txt(attrs)<EOL>txt = "<STR_LIT>" % (edge_from, edge_to, atxt)<EOL>lines.append(txt)<EOL><DEDENT>lines.append("<STR_LIT:}>")<EOL>return '<STR_LIT:\n>'.join(lines)<EOL>
Replacement for pygraph.readwrite.dot.write, which is dog slow.

    Note:
        This isn't a general replacement. It will work for the graphs that
        Rez generates, but there are no guarantees beyond that.

    Args:
        g (`pygraph.digraph`): Input graph.

    Returns:
        str: Graph in dot format.