Agnode_t *node;
int i;
Info_t *ip;
- char *marg;
nsites = agnnodes(graph);
geominit();
node = agfstnode(graph);
ip = nodeInfo;
-#ifdef OLD
- marg = agget(graph, "voro_pmargin");
- if (marg && (*marg != '\0')) {
- pmargin = atof(marg);
- }
-#else
- if ((marg = agget(graph, "sep"))) {
- pmargin = 1.0 + atof(marg);
- } else
- pmargin = 1.01;
-#endif
-
+ pmargin = expFactor (graph);
for (i = 0; i < nsites; i++) {
ip->site.coord.x = ND_pos(node)[0];
ip->site.coord.y = ND_pos(node)[1];
int overlapCnt = 0;
int cnt;
Point center;
- double sc;
+ /* double sc; */
if (!useIter || (iterations > 0))
overlapCnt = countOverlap(iterCnt);
center.x = (pxmin + pxmax) / 2.0;
center.y = (pymin + pymax) / 2.0;
while (1) {
- sc = rePos(center);
+ /* sc = */ rePos(center);
iterCnt++;
if (useIter && (iterCnt == iterations))
{AM_NONE, 0, 0}
};
+/* getAdjustMode:
+ * Convert string value to internal value of adjustment mode.
+ * Assume s != NULL.
+ */
static adjust_data *getAdjustMode(char *s)
{
adjust_data *ap = adjustMode + 2;
+ if (*s == '\0') return adjustMode;
while (ap->attrib) {
if (!strcasecmp(s, ap->attrib))
return ap;
return adjustMode + 1;
}
-void removeOverlap(graph_t * G)
+/* removeOverlapAs:
+ * Use flag value to determine if and how to remove
+ * node overlaps.
+ */
+void
+removeOverlapAs(graph_t * G, char* flag)
{
/* int userWindow = 0; */
- char *flag;
int ret;
extern void cAdjust(graph_t *, int);
extern void scAdjust(graph_t *, int);
if (agnnodes(G) < 2)
return;
- flag = agget(G, "overlap");
if (flag == NULL)
return;
return;
if (Verbose)
- fprintf(stderr, "Adjusting nodes using %s\n", am->print);
+ fprintf(stderr, "Adjusting %s using %s\n", G->name, am->print);
if (am->mode > AM_SCALE) {
/* start_timer(); */
}
+/* removeOverlap:
+ */
+void
+removeOverlap(graph_t * G)
+{
+ removeOverlapAs(G, agget(G, "overlap"));
+}
+
void adjustNodes(graph_t * G)
{
if (agnnodes(G) < 2)
removeOverlap (G);
}
+/* expFactor:
+ * Return factor by which to scale up nodes.
+ */
+double
+expFactor(graph_t* g)
+{
+ double pmargin;
+ char* marg;
+
+ if ((marg = agget(g, "sep"))) {
+ pmargin = 1.0 + atof(marg);
+ } else
+ pmargin = 1.01;
+ return pmargin;
+}
+
#endif
#include "neato.h"
-/* #include "utils.h" */
+#include "adjust.h"
#define SCALE 10
#define SCALE2 (SCALE/2)
edge_t *e;
int lcnt, cnt;
int oldval = -MAXINT;
+#ifdef OLD
double root_val;
+#endif
node_t *lastn = NULL;
/* count distinct nodes */
lastn = n;
} else {
root = n;
+#ifdef OLD
root_val = p->val;
+#endif
lastn = GD_nlist(cg) = n;
}
alloc_elist(lcnt, ND_in(n));
*/
void cAdjust(graph_t * g, int xy)
{
- char *marg;
- double margin = 0;
+ double margin;
int i, nnodes = agnnodes(g);
nitem *nlist = N_GNEW(nnodes, nitem);
nitem *p = nlist;
node_t *n;
- marg = agget(g, "sep");
- if (marg && *marg) {
- margin = atof(marg);
- if (margin > 0)
- margin += 1.0;
- }
- if (margin == 0.0)
- margin = 1.01;
+ margin = expFactor (g);
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
initItem(n, p, margin);
node_t *n;
pointf s;
int i;
- char *marg;
- double margin = 0;
+ double margin;
pointf *aarr;
int m;
- marg = agget(g, "sep");
- if (marg && *marg) {
- margin = atof(marg);
- if (margin > 0)
- margin += 1.0;
- }
- if (margin == 0.0)
- margin = 1.02;
+ margin = expFactor (g);
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
double w2 = margin * ND_width(n) / 2.0;