46#define D_useGrid (fdp_parms->useGrid)
47#define D_useNew (fdp_parms->useNew)
48#define D_numIters (fdp_parms->numIters)
49#define D_unscaled (fdp_parms->unscaled)
50#define D_C (fdp_parms->C)
51#define D_Tfact (fdp_parms->Tfact)
52#define D_K (fdp_parms->K)
53#define D_T0 (fdp_parms->T0)
79#define T_useGrid (parms.useGrid)
80#define T_useNew (parms.useNew)
81#define T_seed (parms.seed)
82#define T_numIters (parms.numIters)
83#define T_maxIters (parms.maxIters)
84#define T_unscaled (parms.unscaled)
86#define T_Tfact (parms.Tfact)
88#define T_T0 (parms.T0)
89#define T_smode (parms.smode)
90#define T_Cell (parms.Cell)
91#define T_Wd (parms.Wd)
92#define T_Ht (parms.Ht)
93#define T_pass1 (parms.pass1)
94#define T_loopcnt (parms.loopcnt)
97#define DFLT_maxIters 600
101#define DFLT_smode INIT_RANDOM
125 fprintf(stderr,
"tlayout %s",
agnameof(g));
171 agwarningf(
"fdp does not support start=self - ignoring\n");
184 fprintf(stderr,
"Params %s : K %f T0 %f Tfact %f maxIters %d unscaled %d\n",
194 while (!(
dist > 0)) {
195 xdelta = 5 - rand() % 10;
196 ydelta = 5 - rand() % 10;
197 dist = hypot(xdelta, ydelta);
205 if (IS_PORT(p) && IS_PORT(q))
207 DISP(q)[0] += xdelta * force;
208 DISP(q)[1] += ydelta * force;
209 DISP(p)[0] -= xdelta * force;
210 DISP(p)[1] -= ydelta * force;
215 double xdelta, ydelta;
219 doRep(p, q, xdelta, ydelta, hypot(xdelta, ydelta));
227 double xdelta, ydelta;
233 fprintf(stderr,
" doNeighbor (%d,%d) : %d\n", i, j,
gLength(cellp));
236 for (; nodes != 0; nodes = nodes->
next) {
238 for (qs = cellp->
nodes; qs != 0; qs = qs->
next) {
242 const double dist = hypot(xdelta, ydelta);
251 cell *
const cellp = c;
262 fprintf(stderr,
"gridRepulse (%d,%d) : %d\n", i, j,
gLength(cellp));
265 for (p = nodes; p != 0; p = p->
next) {
266 for (q = nodes; q != 0; q = q->
next)
287 double xdelta, ydelta;
294 dist2 = xdelta * xdelta + ydelta * ydelta;
295 while (
dist2 == 0.0) {
296 xdelta = 5 - rand() % 10;
297 ydelta = 5 - rand() % 10;
298 dist2 = xdelta * xdelta + ydelta * ydelta;
305 DISP(q)[0] -= xdelta * force;
306 DISP(q)[1] -= ydelta * force;
307 DISP(p)[0] += xdelta * force;
308 DISP(p)[1] += ydelta * force;
331 double fact = temp / sqrt(len2);
342 }
else if (d >= 1.0) {
343 ND_pos(n)[0] = 0.95 * x / d;
344 ND_pos(n)[1] = 0.95 * y / d;
356#define FLOOR(d) ((int)floor(d))
368 DISP(n)[0] = DISP(n)[1] = 0;
392 DISP(n)[0] = DISP(n)[1] = 0;
418 boxf bb = {{0, 0}, {0, 0}};
421 double PItimes2 =
M_PI * 2.0;
438 size =
T_K * (sqrt(nG) + 1.0);
443 }
else if (n_pos > 1) {
444 double alpha, area, width, height, quot;
445 ctr.
x = (bb.
LL.
x + bb.
UR.
x) / 2.0;
446 ctr.
y = (bb.
LL.
y + bb.
UR.
y) / 2.0;
450 quot = width * height / area;
454 }
else if (quot > 0.0) {
455 quot = 2.0 * sqrt(quot);
457 T_Ht = height / quot;
460 height = area / width;
463 }
else if (height > 0) {
464 width = area / height;
485 local_seed = (long)time(
NULL);
535 }
else if (
cnt == 1) {
536 ND_pos(np)[0] = 0.98 * p.
x + 0.1 * ctr.
x;
537 ND_pos(np)[1] = 0.9 * p.
y + 0.1 * ctr.
y;
539 double angle = PItimes2 *
drand48();
540 double radius = 0.9 *
drand48();
574 bport_t *
const pp = PORTS(g);
582 const double temp =
cool(i);
588 const double temp =
cool(i);
593 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)
struct fdpParms_s * fdp_parms
static int cnt(Dict_t *d, Dtlink_t **set)
void adjustGrid(Grid *g, int nnodes)
int gLength(cell *p)
return the number of nodes in a cell
void delGrid(Grid *g)
close and free all grid resources
void walkGrid(Grid *g, int(*walkf)(void *, void *))
void addGrid(Grid *g, int i, int j, Agnode_t *n)
add node n to cell (i,j) in grid g
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
double Mlimit
distance beyond which repulsive force is 0
static bool init_params(graph_t *g, xparams *xpms)
static int gridRepulse(void *c, void *g)
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 updatePos(Agraph_t *g, double temp, bport_t *pp)
static void doNeighbor(Grid *grid, int i, int j, node_list *nodes)
static void doRep(node_t *p, node_t *q, double xdelta, double ydelta, double dist)
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)