title: How can python write a dot file for GraphViz asking for some edges to be colored red?
body: <p>I am using python code (with python nested dicts) to write out a DOT file for GraphViz to draw my directed edge-weighted graph, thanks to DAWG's suggestions...</p>
  <pre><code>nestedg={1: {2: 3, 3: 8, 5: -4}, 
       2: {4: 1, 5: 7}, 
       3: {2: 0.09}, 
       4: {1: 2, 3: -5}, 
       5: {4: 6}}
  
  with open('/tmp/graph.dot','w') as out:
      for line in ('digraph G {','size=&quot;16,16&quot;;','splines=true;'):
          out.write('{}\n'.format(line))  
      for start,d in nestedg.items():
          for end,weight in d.items():
                out.write('{} -&gt; {} [ label=&quot;{}&quot; ];\n'.format(start,end,weight))
      out.write('}\n')
  </code></pre>
  <p>Which produces this .DOT file, from which GraphViz can produce a nice graph image:</p>
  <pre><code>digraph G {
  size=&quot;16,16&quot;;
  splines=true;
  1 -&gt; 2 [ label=&quot;3&quot; ];
  1 -&gt; 3 [ label=&quot;8&quot; ];
  1 -&gt; 5 [ label=&quot;-4&quot; ];
  2 -&gt; 4 [ label=&quot;1&quot; ];
  2 -&gt; 5 [ label=&quot;7&quot; ];
  3 -&gt; 2 [ label=&quot;0.09&quot; ];
  4 -&gt; 1 [ label=&quot;2&quot; ];
  4 -&gt; 3 [ label=&quot;-5&quot; ];
  5 -&gt; 4 [ label=&quot;6&quot; ];
  }
  </code></pre>
  <p>How can I change this python code to ask GraphViz to color an edge RED if its weight is less than a specific number (e.g., 0.5), such as the edge from node 3 to 2 (with a weight of 0.09)?
  And more generally is there a good place to learn much more about how to write python code to create all kinds of DOT files for GraphViz, and to see good examples?</p>