24#define SCALE2 (SCALE/2)
39static int cmpitem(
void *item1,
void *item2) {
40 const int *p1 = item1;
41 const int *p2 = item2;
54 offsetof(
nitem, link),
62 return ((b1->
UR.
y - b1->
LL.
y) + (b2->
UR.
y - b2->
LL.
y)) / 2;
67 return ((b1->
UR.
x - b1->
LL.
x) + (b2->
UR.
x - b2->
LL.
x)) / 2;
89 return ydelta <= xdelta;
111 return xdelta <= ydelta;
158#if defined(DEBUG) && DEBUG > 1
186 assert(outdegree(g,n) ==
ND_out(n).size);
187 for (i = 0; (e =
ND_out(n).list[i]); i++) {
191 assert(indegree(g,n) ==
ND_in(n).size);
192 for (i = 0; (e =
ND_in(n).list[i]); i++) {
244 assert (
delta <= 0xFFFF);
281 int oldval = -INT_MAX;
289 if (oldval != p->
val) {
299 if (oldval != p->
val) {
346 if (oldval != p->
val) {
350 if (nxt->
val != oldval)
356 for (nxp = nxt; nxp; nxp = (
nitem *)
dtlink(list, nxp)) {
395 for (i = 0; i < nnodes; i++) {
407 for (i = 0; i < nnodes; i++) {
433 for (i = 0; i < nnodes; i++) {
451 snprintf(buf,
sizeof(buf),
"%d",
ND_rank(n));
454 snprintf(buf,
sizeof(buf),
"%d",
ED_minlen(e));
462 for (i = 0; i < nnodes; i++) {
485 for (i = 0; i <
cnt - 1; i++) {
487 for (j = i + 1; j <
cnt; j++) {
609 for (i = 0; i < nnodes; i++) {
631static int sortf(
const void *x,
const void *y) {
636 else if (p->
x > q->
x)
638 else if (p->
y < q->
y)
640 else if (p->
y > q->
y)
654 for (i = 0; i < nn; i++) {
656 for (j = i + 1; j < nn; j++) {
689 points_append(&
S, (
pointf){0});
691 for (
size_t i = 0; i < nn; i++) {
693 for (
size_t j = i + 1; j < nn; j++) {
710 points_append(&
S, pt);
717 points_shrink_to_fit(&
S);
718 *cntp = points_size(&
S);
719 return points_detach(&
S);
723 double cost, bestcost;
727 aarr[0].
y = HUGE_VAL;
731 barr[m - 1].
x = aarr[m - 1].
x;
733 for (
size_t k = m - 2; m > 1; k--) {
734 barr[k].
x = aarr[k].
x;
735 barr[k].
y = fmax(aarr[k + 1].y, barr[k + 1].y);
743 for (
size_t k = 0; k < m; k++) {
744 cost = barr[k].
x * barr[k].
y;
745 if (cost < bestcost) {
750 assert(bestcost < HUGE_VAL);
768 for (
size_t i = 1; i < m; i++) {
833 if (
Verbose) fprintf(stderr,
"compress %g \n",
s.x);
851 if (
Verbose) fprintf(stderr,
"scale by %g,%g \n",
s.x,
s.y);
855 for (i = 0; i < nnodes; i++) {
static void newpos(Info_t *ip)
expand_t sepFactor(graph_t *g)
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
CDT_API Dtlink_t * dtflatten(Dt_t *)
CDT_API Dtmethod_t * Dtobag
ordered multiset
CDT_API int dtclose(Dt_t *)
CDT_API Dt_t * dtopen(Dtdisc_t *, Dtmethod_t *)
static graph_t * mkNConstraintG(graph_t *g, Dt_t *list, intersectfn intersect, distfn dist)
static graph_t * mkConstraintG(Dt_t *list, intersectfn intersect, distfn dist)
static int intersectY0(nitem *p, nitem *q)
int scAdjust(graph_t *g, int equal)
int(* intersectfn)(nitem *, nitem *)
static void constrainY(graph_t *g, nitem *nlist, int nnodes, intersectfn ifn, int ortho)
static int distX(box *b1, box *b2)
static void constrainX(graph_t *g, nitem *nlist, int nnodes, intersectfn ifn, int ortho)
static void closeGraph(graph_t *cg)
static pointf computeScaleXY(pointf *aarr, size_t m)
static int distY(box *b1, box *b2)
static int cmpitem(void *item1, void *item2)
static double computeScale(pointf *aarr, size_t m)
static int intersectX(nitem *p, nitem *q)
static void initItem(node_t *n, nitem *p, expand_t margin)
static pointf * mkOverlapSet(info *nl, size_t nn, size_t *cntp)
int(* distfn)(box *, box *)
static int intersectX0(nitem *p, nitem *q)
static int sortf(const void *x, const void *y)
static int overlaps(nitem *p, int cnt)
static void mapGraphs(graph_t *g, graph_t *cg, distfn dist)
static double compress(info *nl, int nn)
int cAdjust(graph_t *g, int mode)
static int intersectY(nitem *p, nitem *q)
static double dist(int dim, double *x, double *y)
geometric types and macros (e.g. points and boxes)
#define PS2INCH(a_points)
static pointf scale(double c, pointf p)
static int cnt(Dict_t *d, Dtlink_t **set)
int agnnodes(Agraph_t *g)
Agsym_t * agattr(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up attributes of a graph
int agxset(void *obj, Agsym_t *sym, const char *value)
Agedge_t * agedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *name, int createflag)
Agedge_t * agnxtin(Agraph_t *g, Agedge_t *e)
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
#define agfindedge(g, t, h)
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)
Agedge_t * agfstin(Agraph_t *g, Agnode_t *n)
int agclose(Agraph_t *g)
deletes a graph, freeing its associated storage
Agdesc_t Agstrictdirected
strict directed. A strict graph cannot have multi-edges or self-arcs.
Agraph_t * agopen(char *name, Agdesc_t desc, Agdisc_t *disc)
creates a new graph with the given name and kind
Agnode_t * agnode(Agraph_t *g, char *name, int createflag)
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.
void * agbindrec(void *obj, const char *name, unsigned int recsize, int move_to_front)
attaches a new record of the given size to the object
#define DEFINE_LIST(name, type)
int rank(graph_t *g, int balance, int maxiter)
static double cg(SparseMatrix A, const double *precond, int n, int dim, double *x0, double *rhs, double tol, double maxit)
#define elist_append(item, L)
#define alloc_elist(n, L)
static bool intersect(Ppoint_t a, Ppoint_t b, Ppoint_t c, Ppoint_t d)