result->size = 1;
result->size = 0;
struct DataBlock *convertTreeToDot(struct TreeAdaptor *ta, double score, struct StringStack *labels, struct CLNodeSet *flips, struct GeneralConfig *cur, struct TreeMaster *tm, gsl_matrix *dm){  int i, j;  struct LabelPerm *labelperm = treegetlabelpermTRA(ta);  struct AdjA *ad = treegetadjaTRA(ta);  struct DoubleA *nodes;  static char labbuf[128];  static char lab[1024];  struct DataBlock *result;  struct StringStack *dotacc;  struct StringStack *params = NULL;  char con1[1024];  int dasize;  char *startparamstr, *endparamstr;  assert(ad);  nodes = simpleWalkTree(ta, flips);  dasize = adjaSize(ad);  assert(dasize > 0);  assert(getSize(nodes) == dasize);  dotacc = newStringStack();  assert(dotacc);  assert(labelperm);  pushSS(dotacc, "graph \"tree\" {");  if (cur && cur->fSuppressVisibleDetails) {    startparamstr = "/* "; endparamstr = " */";  } else {    pushSS(dotacc, "label=\"\\");    startparamstr = ""; endparamstr = "\\n\\";  }  sprintf(con1, "%s%s version %s%s", startparamstr, PACKAGE_NAME,      PACKAGE_VERSION, endparamstr);  pushSS(dotacc, con1);  if (score != 0.0) {    sprintf(con1, "%stree score S(T) = %f%s", startparamstr, score,        endparamstr);    pushSS(dotacc, con1);  }  if (cur) {    params = convertParamsToStringStack(cur->em, startparamstr, endparamstr);    for (i = 0; i < sizeSS(params); i += 1)      pushSS(dotacc, readAtSS(params,i));  }  if (!(cur && cur->fSuppressVisibleDetails))    pushSS(dotacc, "\";");  if (cur) {    for (i = 0; i < sizeSS(cur->cmdKeeper); i += 1) {      char *cmd = readAtSS(cur->cmdKeeper, i);      sprintf(con1, "/* Step %d: %s */", i+1, cmd);      pushSS(dotacc, con1);    }  }  if (tm) {    int t0, tf, dt;    if (getStartTimeTM(tm)) {      sprintf(con1, "/* start time %s */", cldt_to_humstr(getStartTimeTM(tm)));      pushSS(dotacc, con1);    }    if (getEndTimeTM(tm)) {      sprintf(con1, "/* end   time %s */", cldt_to_humstr(getEndTimeTM(tm)));      pushSS(dotacc, con1);    }    sprintf(con1, "/* total trees: %d */", totalTreesExamined(tm));    pushSS(dotacc, con1);    if (getEndTimeTM(tm) && getStartTimeTM(tm)) {      t0 = cldt_to_i(getStartTimeTM(tm));      tf = cldt_to_i(getEndTimeTM(tm));      dt = tf - t0;      if (dt > 0) {        sprintf(con1, "/* trees / sec : %f */", totalTreesExamined(tm) /            (double) dt);        pushSS(dotacc, con1);      }    }  }  sprintf(con1,"/* Hostname: %s */", getHostname());  pushSS(dotacc,con1);  sprintf(con1,"/* Machine desc: %s */", getUTSName());  pushSS(dotacc,con1);  sprintf(con1,"/* PID: %d */", getPID());  pushSS(dotacc,con1);  int rootnode = -1;  for (i = 0; i < dasize; i += 1) {    int nodenum = getValueAt(nodes, i).i;    assert(nodenum >= 0 && nodenum <= 3 * dasize);    char *str;    char *extrastr = "";    if (treeIsRoot(ta, nodenum)) {      extrastr=",style=bold";      rootnode = nodenum;    }    if (treeIsQuartettable(ta, nodenum) && labels)      str = readAtSS(labels, getColumnIndexForNodeIDLP(labelperm,nodenum));    else {      sprintf(labbuf, "%c%d", treeIsQuartettable(ta, nodenum) ? 'L' : 'k', nodenum);      str = labbuf;    }    sprintf(lab,"%d [label=\"%s\"%s];", nodenum, str, extrastr);    pushSS(dotacc, lab);  }  for (i = 0; i < dasize; i += 1) {    int n1 = getValueAt(nodes, i).i;    assert(n1 >= 0 && n1 <= 3 * dasize);    sprintf(con1, "%d", n1);    for (j = 0; j < dasize; j += 1) {      int n2 = getValueAt(nodes, j).i;//      printf("For %d, got %d on labelperm %p\n", j, n2, labelperm);      assert(n2 >= 0 && n2 <= 3 * dasize);      char con2[1024];      sprintf(con2, "%d", n2);      if (n1 > n2 && adjaGetConState(ad, n1, n2)) {        char buf[4096];        sprintf(buf, "%s -- %s [weight=\"2\"];", con1, con2);        pushSS(dotacc, buf);      }    }  }  if (rootnode != -1) {    sprintf(lab,"%d [label=\"%s\",color=white,fontcolor=black];", 9999, "root");    pushSS(dotacc, lab);    sprintf(lab,"%d -- %d;", 9999, rootnode);    pushSS(dotacc, lab);  }  /* Perimeter walker */  if (flips)  {    int i;    struct DoubleA *dapairs;    dapairs = treeperimpairsTRA(ta, flips);    for (i = 0; i < getSize(dapairs); i += 1) {      int dmx = getColumnIndexForNodeIDLP(labelperm,getValueAt(dapairs,i).ip.x);      int dmy = getColumnIndexForNodeIDLP(labelperm,getValueAt(dapairs,i).ip.y);      double disthere = gsl_matrix_get(dm, dmx, dmy);      sprintf(lab, "i%d [label=\"%03.3f\",color=\"white\"];", i, disthere);      pushSS(dotacc, lab);      sprintf(lab, "i%d -- %d [style=\"dotted\"];",  i, getValueAt(dapairs, i).ip.x);      pushSS(dotacc, lab);      sprintf(lab, "i%d -- %d [style=\"dotted\"];",  i, getValueAt(dapairs, i).ip.y);      pushSS(dotacc, lab);    }    freeDoubleDoubler(dapairs);  }  pushSS(dotacc, "}");  result = gcalloc(sizeof(struct DataBlock), 1);  result->size = 1; /* for the terminal nul */  for (i = 0; i < sizeSS(dotacc); i += 1)    result->size += strlen(readAtSS(dotacc, i)) + 1; /* for the \n */  result->ptr = gcalloc(result->size, 1);  j = 0;  for (i = 0; i < sizeSS(dotacc); i += 1)    j += sprintf((char *) (result->ptr + j), "%s\n", readAtSS(dotacc, i));  freeSS(dotacc);  if (cur && params)    freeSS(params);  freeDoubleDoubler(nodes);  return result;}