/* canon:
* Canonicalize a string which may not have been allocated using agstrdup.
*/
-static char* canon (char* s)
+static char* canon (graph_t *g, char* s)
{
- char* ns = agstrdup (s);
#ifndef WITH_CGRAPH
+ char* ns = agstrdup (s);
char* cs = agcanonical (ns);
+ agstrfree (ns);
#else
+ char* ns = agstrdup (g, s);
char* cs = agcanonStr (ns);
+ agstrfree (g, ns);
#endif
- agstrfree (ns);
return cs;
}
{
char *name;
if (IS_CLUST_NODE(node))
- name = canon (strchr(agnameof(node), ':') + 1);
+ name = canon (agraphof(node), strchr(agnameof(node), ':') + 1);
else
#ifndef WITH_CGRAPH
name = agcanonical (agnameof(node));
lbl = agcanonStr (agxget(n, N_label));
#endif
else
-#ifndef WITH_CGRAPH
- lbl = canon(ND_label(n)->text);
-#else
lbl = canon(agraphof(n),ND_label(n)->text);
-#endif
fprintf(f, " %.5g %.5g %s %s %s %s %s\n",
ND_width(n), ND_height(n), lbl,
late_nnstring(n, N_style, "solid"),
}
}
if (ED_label(e)) {
-#ifndef WITH_CGRAPH
- fprintf(f, " %s", canon(ED_label(e)->text));
-#else
fprintf(f, " %s", canon(agraphof(e),ED_label(e)->text));
-#endif
printptf(f, ED_label(e)->pos);
}
fprintf(f, " %s %s\n", late_nnstring(e, E_style, "solid"),
#ifdef WITH_CGRAPH
#include "cgraph.h"
+#define SET_RANKDIR(g,rd) (GD_rankdir2(g) = rd)
#else
#include "graph.h"
+#define SET_RANKDIR(g,rd) ((g)->u.rankdir = (rd))
+#define agnameof(x) ((x)->name)
+ /* warning, agraphof doesn't work for edges */
+#define agraphof(n) ((n)->graph)
+#define agroot(g) ((g)->root)
+#define aghead(e) ((e)->head)
+#define agtail(e) ((e)->tail)
+#define agisdirected(g) ((g)->kind & AGFLAG_DIRECTED)
+#define AGID(x) ((x)->id)
#endif
+
typedef struct {
int useGrid; /* use grid for speed up */
int useNew; /* encode x-K into attractive force */