def graph_to_dot(graph, node_renderer=None, edge_renderer=None):
node_pairs = list(graph.nodes.items())<EOL>edge_pairs = list(graph.edges.items())<EOL>if node_renderer is None:<EOL><INDENT>node_renderer_wrapper = lambda nid: '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>node_renderer_wrapper = lambda nid: '<STR_LIT>' % '<STR_LIT:U+002C>'.join(<EOL>['<STR_LIT>' % tpl for tpl in list(node_renderer(graph, nid).items())])<EOL><DEDENT>graph_string = '<STR_LIT>'<EOL>graph_string += '<STR_LIT>'<EOL>for node_id, node in node_pairs:<EOL><INDENT>graph_string += '<STR_LIT>' % (node_id, node_renderer_wrapper(node_id))<EOL><DEDENT>for edge_id, edge in edge_pairs:<EOL><INDENT>node_a = edge['<STR_LIT>'][<NUM_LIT:0>]<EOL>node_b = edge['<STR_LIT>'][<NUM_LIT:1>]<EOL>graph_string += '<STR_LIT>' % (node_a, node_b)<EOL><DEDENT>graph_string += '<STR_LIT:}>'<EOL>return graph_string<EOL>
Produces a DOT specification string from the provided graph.