--- doxygen-1.6.3/src/dot.cpp	2010-02-19 15:24:20.000000000 -0500
+++ doxygen-1.6.3.patched/src/dot.cpp	2011-10-11 15:47:35.304365000 -0400
@@ -23,4 +23,5 @@
 
 #include <stdlib.h>
+#include <ctype.h>
 
 #include "dot.h"
@@ -41,4 +42,5 @@
 #include <qtextstream.h>
 #include <md5.h>
+#include <iostream>
 
 #define MAP_CMD "cmapx"
@@ -581,7 +583,64 @@
 }
 
-static QCString convertLabel(const QCString &l)
+/// \brief Fold long names.
+/// Really long names make for bad graphs because the boxes become very elongated.
+/// This folds the names at reasonable places to turn a long one-line name into
+/// several lines.
+/// \param l a name of a file, class, method, function, or similar.
+/// \param foldlength is an lower bound to the length of the name after folding
+/// \return a string, with folds indicated by inserted '\n' characters.
+static QCString foldIfLong(const QCString &l, int foldlength=17)
 {
   QCString result;
+  if(l.isEmpty()) return result;
+  const QCString bbfore("\\/_/<({[: =-+@%#~?"), bafter(">]),;|$");
+  const char *p=l.data(), *e = p+l.length();
+  int sincelast=0;
+  for(; p<e; p++)
+  {
+    if(*p == '\n')
+    {
+      result += *p;
+      sincelast = 1;
+      foldlength = (3*foldlength+sincelast+2)/4;
+    }
+    else if(e-p > foldlength/3 && sincelast>foldlength && bbfore.contains(*p))
+    {
+      result += '\n';
+      result += *p;
+      foldlength = (foldlength+sincelast+1)/2;
+      sincelast = 1;
+    }
+    else if(e-p > 1+foldlength/4 && sincelast>foldlength+foldlength/3 && !isupper(p[0]) && isupper(p[1]))
+    {
+      result += *p;
+      result += '\n';
+      foldlength = (foldlength+sincelast+1)/2;
+      sincelast = 1;
+    }
+    else if(e-p > foldlength/3 && sincelast>foldlength && bafter.contains(*p))
+    {
+      result += *p;
+      result += '\n';
+      foldlength = (foldlength+sincelast+1)/2;
+      sincelast = 1;
+    }
+    else
+    {
+      result += *p;
+      sincelast += 1;
+    }
+  }
+ // if(result != l)
+	// std::cerr << "Folding " << l << " to " << result << "\n";
+  return result;
+}
+
+
+
+static QCString convertLabel(const QCString &ll)
+{
+  QCString l(foldIfLong(ll));
+  QCString result;
   const char *p=l.data();
   if (p==0) return result;
@@ -2970,5 +3029,5 @@
         QCString tooltip = def->briefDescriptionAsTooltip();
         nnode = new DotNode(m_curNodeId++, def->groupTitle(), tooltip, tmp_url );
-        nnode->markAsVisible();
+        
         m_usedNodes->insert(def->name(), nnode );
       }
