20Allow sep to be absolute additive (margin of n
points)
32#define DFLT_overlap "9:prism"
83 fprintf(stderr,
"xLayout ");
84 pr2graphs(g,GORIG(
agroot(g)));
85 fprintf(stderr,
" : n = %d K = %f T0 = %f loop %d C %f\n",
93#define X_T0 xParams.T0
95#define X_numIters xParams.numIters
96#define X_loopcnt xParams.loopcnt
110 const double xdelta = fabs(
ND_pos(q)[0] -
ND_pos(p)[0]);
111 const double ydelta = fabs(
ND_pos(q)[1] -
ND_pos(p)[1]);
112 return xdelta <=
WD2(p) +
WD2(q) && ydelta <=
HT2(p) +
HT2(q);
134 double dist2,
double X_ov,
double X_nonov) {
138 while (
dist2 == 0.0) {
139 xdelta = 5 - rand() % 10;
140 ydelta = 5 - rand() % 10;
141 dist2 = xdelta * xdelta + ydelta * ydelta;
144 force = X_ov /
dist2;
146 force = X_nonov /
dist2;
151 fprintf(stderr,
" ov Fr %f dist %f\n", force *
dist,
dist);
154 DISP(q)[0] += xdelta * force;
155 DISP(q)[1] += ydelta * force;
156 DISP(p)[0] -= xdelta * force;
157 DISP(p)[1] -= ydelta * force;
168 return doRep(p, q, xdelta, ydelta, xdelta * xdelta + ydelta * ydelta, X_ov,
178 fprintf(stderr,
"ov 1 Fa 0 din %f\n",
RAD(p) +
RAD(q));
185 const double dist = hypot(xdelta, ydelta);
186 const double din =
RAD(p) +
RAD(q);
187 const double dout =
dist - din;
188 const double force = dout * dout / ((
X_K + din) *
dist);
192 fprintf(stderr,
" ov 0 Fa %f din %f \n", force *
dist, din);
195 DISP(q)[0] -= xdelta * force;
196 DISP(q)[1] -= ydelta * force;
197 DISP(p)[0] += xdelta * force;
198 DISP(p)[1] += ydelta * force;
210 fprintf(stderr,
"=================\n");
214 DISP(n)[0] = DISP(n)[1] = 0;
220 ov =
applyRep(n, n1, X_ov, X_nonov);
230 const double temp2 = temp * temp;
234 const double disp[] = {DISP(n)[0], DISP(n)[1]};
235 const double len2 = disp[0] * disp[0] + disp[1] * disp[1];
242 const double len = sqrt(len2);
277 const double K = xpms.
K;
278 for (
int try = 0; ov &&
try < tries; ++
try) {
280 const double X_ov =
X_C * K2;
281 const double X_nonov =
nedges * X_ov * 2.0 / (nnodes * (nnodes - 1));
285 fprintf(stderr,
"try %d (%d): %d overlaps on ",
try, tries, ov);
286 pr2graphs(g,GORIG(
agroot(g)));
287 fprintf(stderr,
" \n");
292 const double temp =
cool(i);
295 ov =
adjust(g, temp, X_ov, X_nonov);
303 fprintf(stderr,
"Warning: %d overlaps remain on ", ov);
304 pr2graphs(g,GORIG(
agroot(g)));
305 fprintf(stderr,
"\n");
327 char* ovlp =
agget (g,
"overlap");
335 fprintf (stderr,
"xLayout ");
337 if (!ovlp || *ovlp ==
'\0') {
341 if ((cp = strchr(ovlp,
':')) && (cp == ovlp ||
gv_isdigit(*ovlp))) {
345 if (tries < 0) tries = 0;
355 fprintf (stderr,
"tries = %d, mode = %s\n", tries, rest);
357 if (tries && !
x_layout(g, xpms, tries))
expand_t sepFactor(graph_t *g)
int removeOverlapAs(graph_t *G, char *flag)
Use flag value to determine if and how to remove node overlaps.
static int overlaps(nitem *p, int cnt)
static const char adjust[]
static double dist(int dim, double *x, double *y)
#define PS2INCH(a_points)
static double len(glCompPoint p)
static int cnt(Dict_t *d, Dtlink_t **set)
int agnedges(Agraph_t *g)
int agnnodes(Agraph_t *g)
char * agget(void *obj, char *name)
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
char * agnameof(void *)
returns a string descriptor for the object.
Agraph_t * agroot(void *obj)
replacements for ctype.h functions
static bool gv_isdigit(int c)
static int between(double f, double g, double h)
PATHUTIL_API COORD dist2(Ppoint_t, Ppoint_t)
static int nedges
total no. of edges used in routing
static int cntOverlaps(graph_t *g)
static double WD2(Agnode_t *n)
static int x_layout(graph_t *g, xparams *pxpms, int tries)
static double xinit_params(graph_t *g, int n, xparams *xpms)
static double RAD(Agnode_t *n)
static int overlap(node_t *p, node_t *q)
static int applyRep(Agnode_t *p, Agnode_t *q, double X_ov, double X_nonov)
static void applyAttr(Agnode_t *p, Agnode_t *q)
void fdp_xLayout(graph_t *g, xparams *xpms)
static int doRep(node_t *p, node_t *q, double xdelta, double ydelta, double dist2, double X_ov, double X_nonov)