25#define SCALE2 (SCALE/2)
40static int cmpitem(
void *item1,
void *item2) {
41 const int *p1 = item1;
42 const int *p2 = item2;
55 offsetof(
nitem, link),
63 return ((b1->
UR.
y - b1->
LL.
y) + (b2->
UR.
y - b2->
LL.
y)) / 2;
68 return ((b1->
UR.
x - b1->
LL.
x) + (b2->
UR.
x - b2->
LL.
x)) / 2;
90 return ydelta <= xdelta;
112 return xdelta <= ydelta;
159#if defined(DEBUG) && DEBUG > 1
187 assert(outdegree(g,n) ==
ND_out(n).size);
188 for (i = 0; (e =
ND_out(n).list[i]); i++) {
192 assert(indegree(g,n) ==
ND_in(n).size);
193 for (i = 0; (e =
ND_in(n).list[i]); i++) {
245 assert (
delta <= 0xFFFF);
282 int oldval = -INT_MAX;
290 if (oldval != p->
val) {
300 if (oldval != p->
val) {
347 if (oldval != p->
val) {
351 if (nxt->
val != oldval)
357 for (nxp = nxt; nxp; nxp = (
nitem *)
dtlink(list, nxp)) {
396 for (i = 0; i < nnodes; i++) {
408 for (i = 0; i < nnodes; i++) {
434 for (i = 0; i < nnodes; i++) {
460 for (i = 0; i < nnodes; i++) {
483 for (i = 0; i <
cnt - 1; i++) {
485 for (j = i + 1; j <
cnt; j++) {
607 for (i = 0; i < nnodes; i++) {
629static int sortf(
const void *x,
const void *y) {
634 else if (p->
x > q->
x)
636 else if (p->
y < q->
y)
638 else if (p->
y > q->
y)
652 for (i = 0; i < nn; i++) {
654 for (j = i + 1; j < nn; j++) {
687 points_append(&
S, (
pointf){0});
689 for (
size_t i = 0; i < nn; i++) {
691 for (
size_t j = i + 1; j < nn; j++) {
708 points_append(&
S, pt);
715 points_shrink_to_fit(&
S);
716 *cntp = points_size(&
S);
717 return points_detach(&
S);
721 double cost, bestcost;
725 aarr[0].
y = HUGE_VAL;
729 barr[m - 1].
x = aarr[m - 1].
x;
731 for (
size_t k = m - 2; m > 1; k--) {
732 barr[k].
x = aarr[k].
x;
733 barr[k].
y = fmax(aarr[k + 1].y, barr[k + 1].y);
741 for (
size_t k = 0; k < m; k++) {
742 cost = barr[k].
x * barr[k].
y;
743 if (cost < bestcost) {
748 assert(bestcost < HUGE_VAL);
766 for (
size_t i = 1; i < m; i++) {
831 if (
Verbose) fprintf(stderr,
"compress %g \n",
s.x);
849 if (
Verbose) fprintf(stderr,
"scale by %g,%g \n",
s.x,
s.y);
853 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_text(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up text 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)