title: How can I optimize GraphViz output width?
body: <p>I make graphs that have huge width ratio: they are 51706 x 503 pixels in size.
  How can I tell GraphViz to optimize width ?</p>
  <p>Note 1: the graph is in fact a tree with each node having a lot of children.
  Here is a <a href="https://9099831083452856398-a-1802744773732722657-s-sites.googlegroups.com/site/faivrem/home/myteacher/best_node.svg?attachauth=ANoY7cqLGm936eOGjRks95aqfrt-Da0peR4y1OfybiKGH6PN-oJgyA2G239UTtpqbW0Sm_3fgrWbNtKSQBine-dirDQPIJG8uNsCpW1BSUXVOcAP3Cni3Jewgz5mdfV9g7FToe3sA6R1YUGcXscy4w8MTpdB_C_G4O51yBwwwAN4r9bqk4Ph08O2KIoPZIeKcGJqV2guNFCLRuwh5wc9jre0ST7dPxWNXw%3D%3D&amp;attredirects=1" rel="nofollow noreferrer">sample</a>.</p>
  <p>Note 2: I think I use dot :)</p>
  <p>Note 3: Here is the <a href="https://gist.github.com/1062005" rel="nofollow noreferrer">Ruby code</a></p>
  <pre><code>def graph_node(n, parent=nil, depth=0)
    #print n, &quot; &quot;
    gn = @g.add_node(n.object_id.to_s, :label=&gt;n.to_graphviz, :shape=&gt;&quot;Mrecord&quot;)
    if parent
      e = @g.add_edge(parent, gn)
    end
    if n == @current_pos_node
      gn[:color] = &quot;brown3&quot;
      gn[:style] = &quot;filled&quot;
    elsif @s.tree.pv(@current_pos_node).include?(n)
      gn[:color] = &quot;cadetblue&quot;
      gn[:style] = &quot;filled&quot;
    elsif @s.tree.pv(@root).include?(n)
      gn[:color] = &quot;yellow&quot;
      gn[:style] = &quot;filled&quot;
    end
    return if !n.children # or depth == 2
    i = 0
    for c in n.children
      graph_node(c, gn, depth+1)
      i += 1
      #break if i &gt; 2
    end
  end
  
  def graph(name=&quot;tree&quot;, root_node=@current_pos_node)
    @g = GraphViz::new(&quot;G&quot;)
    #@g['sep'] = &quot;10,100&quot;
    #@g[&quot;overlap&quot;] = &quot;compress&quot;
    #@g[&quot;rankdir&quot;] = &quot;BT&quot;
    #@g[&quot;ratio&quot;] = &quot;0.9&quot;
    @g[&quot;size&quot;] = &quot;350,500&quot;
    graph_node(root_node)
    @g.output(:svg =&gt; &quot;#{name}.svg&quot;)
  end
  </code></pre>