49#define D_useGrid (fdp_parms->useGrid)
50#define D_useNew (fdp_parms->useNew)
51#define D_numIters (fdp_parms->numIters)
52#define D_unscaled (fdp_parms->unscaled)
53#define D_C (fdp_parms->C)
54#define D_Tfact (fdp_parms->Tfact)
55#define D_K (fdp_parms->K)
56#define D_T0 (fdp_parms->T0)
82#define T_useGrid (parms.useGrid)
83#define T_useNew (parms.useNew)
84#define T_seed (parms.seed)
85#define T_numIters (parms.numIters)
86#define T_maxIters (parms.maxIters)
87#define T_unscaled (parms.unscaled)
89#define T_Tfact (parms.Tfact)
91#define T_T0 (parms.T0)
92#define T_smode (parms.smode)
93#define T_Cell (parms.Cell)
94#define T_Wd (parms.Wd)
95#define T_Ht (parms.Ht)
96#define T_pass1 (parms.pass1)
97#define T_loopcnt (parms.loopcnt)
100#define DFLT_maxIters 600
104#define DFLT_smode INIT_RANDOM
128 fprintf(stderr,
"tlayout %s",
agnameof(g));
174 agwarningf(
"fdp does not support start=self - ignoring\n");
187 fprintf(stderr,
"Params %s : K %f T0 %f Tfact %f maxIters %d unscaled %d\n",
198 while (
dist2 == 0.0) {
199 xdelta = 5 - rand() % 10;
200 ydelta = 5 - rand() % 10;
201 dist2 = xdelta * xdelta + ydelta * ydelta;
208 if (IS_PORT(p) && IS_PORT(q))
210 DISP(q)[0] += xdelta * force;
211 DISP(q)[1] += ydelta * force;
212 DISP(p)[0] -= xdelta * force;
213 DISP(p)[1] -= ydelta * force;
218 double xdelta, ydelta;
222 doRep(p, q, xdelta, ydelta, xdelta * xdelta + ydelta * ydelta);
230 double xdelta, ydelta;
237 fprintf(stderr,
" doNeighbor (%d,%d) : %d\n", i, j,
gLength(cellp));
240 for (; nodes != 0; nodes = nodes->
next) {
242 for (qs = cellp->
nodes; qs != 0; qs = qs->
next) {
246 dist2 = xdelta * xdelta + ydelta * ydelta;
264 fprintf(stderr,
"gridRepulse (%d,%d) : %d\n", i, j,
gLength(cellp));
267 for (p = nodes; p != 0; p = p->
next) {
268 for (q = nodes; q != 0; q = q->
next)
289 double xdelta, ydelta;
296 dist2 = xdelta * xdelta + ydelta * ydelta;
297 while (
dist2 == 0.0) {
298 xdelta = 5 - rand() % 10;
299 ydelta = 5 - rand() % 10;
300 dist2 = xdelta * xdelta + ydelta * ydelta;
307 DISP(q)[0] -= xdelta * force;
308 DISP(q)[1] -= ydelta * force;
309 DISP(p)[0] += xdelta * force;
310 DISP(p)[1] += ydelta * force;
333 double fact = temp / sqrt(len2);
344 }
else if (d >= 1.0) {
345 ND_pos(n)[0] = 0.95 * x / d;
346 ND_pos(n)[1] = 0.95 * y / d;
358#define FLOOR(d) ((int)floor(d))
370 DISP(n)[0] = DISP(n)[1] = 0;
394 DISP(n)[0] = DISP(n)[1] = 0;
420 boxf bb = {{0, 0}, {0, 0}};
423 double PItimes2 =
M_PI * 2.0;
440 size =
T_K * (sqrt((
double)nG) + 1.0);
445 }
else if (n_pos > 1) {
446 double alpha, area, width, height, quot;
447 ctr.
x = (bb.
LL.
x + bb.
UR.
x) / 2.0;
448 ctr.
y = (bb.
LL.
y + bb.
UR.
y) / 2.0;
452 quot = width * height / area;
456 }
else if (quot > 0.0) {
457 quot = 2.0 * sqrt(quot);
459 T_Ht = height / quot;
462 height = area / width;
465 }
else if (height > 0) {
466 width = area / height;
488 local_seed = (long)time(
NULL);
490 local_seed = getpid() ^ time(
NULL);
541 }
else if (
cnt == 1) {
542 ND_pos(np)[0] = 0.98 * p.
x + 0.1 * ctr.
x;
543 ND_pos(np)[1] = 0.9 * p.
y + 0.1 * ctr.
y;
545 double angle = PItimes2 *
drand48();
546 double radius = 0.9 *
drand48();
580 bport_t *
const pp = PORTS(g);
588 const double temp =
cool(i);
594 const double temp =
cool(i);
599 if (ctr.
x != 0.0 || ctr.
y != 0.0) {
int late_int(void *obj, attrsym_t *attr, int defaultValue, int minimum)
double late_double(void *obj, attrsym_t *attr, double defaultValue, double minimum)
static const char adjust[]
static double dist(int dim, double *x, double *y)
static int cnt(Dict_t *d, Dtlink_t **set)
void walkGrid(Grid *g, int(*walkf)(cell *, Grid *))
void adjustGrid(Grid *g, int nnodes)
void addGrid(Grid *g, int i, int j, Agnode_t *n)
cell * findGrid(Grid *g, int i, int j)
Grid * mkGrid(int cellHint)
int agnnodes(Agraph_t *g)
Agsym_t * agattr_text(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up text attributes of a graph
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Agedge_t * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
void agwarningf(const char *fmt,...)
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.
int setSeed(graph_t *G, int dflt, long *seedp)
PATHUTIL_API COORD dist2(Ppoint_t, Ppoint_t)
Agraph_t * root
subgraphs - ancestors
result of partitioning available space, part of maze
static bool init_params(graph_t *g, xparams *xpms)
static int gridRepulse(cell *cellp, Grid *grid)
void fdp_initParams(graph_t *g)
initialize parameters based on root graph attributes
static void applyAttr(Agnode_t *p, Agnode_t *q, Agedge_t *e)
static pointf initPositions(graph_t *g, bport_t *pp)
static void applyRep(Agnode_t *p, Agnode_t *q)
repulsive force = K × K ÷ d or K × K ÷ d × d
static void doRep(node_t *p, node_t *q, double xdelta, double ydelta, double dist2)
static void updatePos(Agraph_t *g, double temp, bport_t *pp)
static void doNeighbor(Grid *grid, int i, int j, node_list *nodes)
void fdp_tLayout(graph_t *g, xparams *xpms)
static void reset_params(void)
static void gAdjust(Agraph_t *g, double temp, bport_t *pp, Grid *grid)
static void clearGrid(grid_t *g)