Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
adjust.c File Reference
#include <assert.h>
#include <neatogen/neato.h>
#include <common/utils.h>
#include <float.h>
#include <math.h>
#include <neatogen/voronoi.h>
#include <neatogen/info.h>
#include <neatogen/edges.h>
#include <neatogen/site.h>
#include <neatogen/hedges.h>
#include <neatogen/digcola.h>
#include <stdbool.h>
#include <stddef.h>
#include <util/agxbuf.h>
#include <util/alloc.h>
#include <util/gv_ctype.h>
#include <util/startswith.h>
#include <util/strcasecmp.h>
Include dependency graph for adjust.c:

Go to the source code of this file.

Data Structures

struct  state_t
 information the ID allocator needs to do its job More...
 
struct  lookup_t
 

Macros

#define SEPFACT   0.8
 
#define ELS   "|edgelabel|"
 
#define IS_LNODE(n)   startswith(agnameof(n), ELS)
 
#define ISZERO(d)   (fabs(d) < 0.000000001)
 

Functions

static void setBoundBox (state_t *st, Point *ll, Point *ur)
 
static void freeNodes (void)
 Free node resources.
 
static void chkBoundBox (state_t *st, Agraph_t *graph)
 
static int makeInfo (Agraph_t *graph)
 For each node in the graph, create a Info data structure.
 
static int scomp (const void *S1, const void *S2)
 
static void sortSites (state_t *st)
 Fill array of pointer to sites and sort the sites using scomp.
 
static void geomUpdate (state_t *st, int doSort)
 
static SitenextOne (void *state)
 
static void rmEquality (state_t *st)
 Check for nodes with identical positions and tweak the positions.
 
static unsigned countOverlap (unsigned iter)
 Count number of node-node overlaps at iteration iter.
 
static void increaseBoundBox (state_t *st)
 
static double areaOf (Point a, Point b, Point c)
 Area of triangle whose vertices are a,b,c.
 
static void centroidOf (Point a, Point b, Point c, double *x, double *y)
 
static void newpos (Info_t *ip)
 
static void addCorners (const state_t *st)
 
static void newPos (const state_t *st, bool doAll)
 
static void cleanup (void)
 
static int vAdjust (state_t *st)
 
static void rePos (void)
 
static int sAdjust (state_t *st)
 
static void updateGraph (void)
 Enter new node positions into the graph.
 
double * getSizes (Agraph_t *g, pointf pad, int *n_elabels, int **elabels)
 Set up array of half sizes in inches.
 
SparseMatrix makeMatrix (Agraph_t *g)
 
static int angleSet (graph_t *g, double *phi)
 
int normalize (graph_t *g)
 
static void setPrismValues (Agraph_t *g, const char *s, adjust_data *dp)
 Initialize and set prism values.
 
static void getAdjustMode (Agraph_t *g, const char *s, adjust_data *dp)
 Convert string value to internal value of adjustment mode.
 
void graphAdjustMode (graph_t *G, adjust_data *dp, char *dflt)
 
static int simpleScale (graph_t *g)
 
int removeOverlapWith (graph_t *G, adjust_data *am)
 
int removeOverlapAs (graph_t *G, char *flag)
 Use flag value to determine if and how to remove node overlaps.
 
int adjustNodes (graph_t *G)
 
static int parseFactor (char *s, expand_t *pp, double sepfact, double dflt)
 
expand_t sepFactor (graph_t *g)
 
expand_t esepFactor (graph_t *g)
 

Variables

static const double incr = 0.05
 
static const lookup_t adjustMode []
 

Macro Definition Documentation

◆ ELS

#define ELS   "|edgelabel|"

Definition at line 524 of file adjust.c.

◆ IS_LNODE

#define IS_LNODE (   n)    startswith(agnameof(n), ELS)

Definition at line 526 of file adjust.c.

◆ ISZERO

#define ISZERO (   d)    (fabs(d) < 0.000000001)

Definition at line 885 of file adjust.c.

◆ SEPFACT

#define SEPFACT   0.8

Definition at line 42 of file adjust.c.

Function Documentation

◆ addCorners()

static void addCorners ( const state_t st)
static

Definition at line 356 of file adjust.c.

References addVertex(), Site::coord, dist_2(), state_t::ne, nodeInfo, nsites, state_t::nw, state_t::se, Info_t::site, state_t::sw, Point::x, and Point::y.

Referenced by newPos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ adjustNodes()

int adjustNodes ( graph_t G)

Definition at line 1022 of file adjust.c.

References agget(), G, and removeOverlapAs().

Referenced by circoLayout(), init_nop(), and twopi_layout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ angleSet()

static int angleSet ( graph_t g,
double *  phi 
)
static

Definition at line 713 of file adjust.c.

References agget(), mapbool(), and RADIANS.

Referenced by normalize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ areaOf()

static double areaOf ( Point  a,
Point  b,
Point  c 
)
static

Definition at line 313 of file adjust.c.

References Point::x, and Point::y.

Referenced by newpos().

Here is the caller graph for this function:

◆ centroidOf()

static void centroidOf ( Point  a,
Point  b,
Point  c,
double *  x,
double *  y 
)
static

Definition at line 321 of file adjust.c.

References Point::x, and Point::y.

Referenced by newpos().

Here is the caller graph for this function:

◆ chkBoundBox()

static void chkBoundBox ( state_t st,
Agraph_t graph 
)
static

Definition at line 86 of file adjust.c.

References agget(), Site::coord, Poly::corner, graph(), nodeInfo, nsites, Poly::origin, Info_t::poly, setBoundBox(), Info_t::site, Point::x, and Point::y.

Referenced by removeOverlapWith().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup()

static void cleanup ( void  )
static

Definition at line 422 of file adjust.c.

References edgeinit(), ELcleanup(), and siteinit().

Referenced by vAdjust().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ countOverlap()

static unsigned countOverlap ( unsigned  iter)
static

Definition at line 274 of file adjust.c.

References Site::coord, nodeInfo, nsites, overlaps(), Info_t::overlaps, Info_t::poly, polyOverlap(), Info_t::site, and Verbose.

Referenced by sAdjust(), and vAdjust().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ esepFactor()

expand_t esepFactor ( graph_t g)

Definition at line 1094 of file adjust.c.

References agget(), DFLT_MARGIN, expand_t::doAdd, parseFactor(), SEPFACT, Verbose, expand_t::x, and expand_t::y.

Referenced by splineEdges().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ freeNodes()

static void freeNodes ( void  )
static

Definition at line 67 of file adjust.c.

References breakPoly(), free(), nodeInfo, nsites, NULL, polyFree(), and Info_t::verts.

Referenced by removeOverlapWith().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ geomUpdate()

static void geomUpdate ( state_t st,
int  doSort 
)
static

Definition at line 201 of file adjust.c.

References Site::coord, deltax, nsites, state_t::sites, sortSites(), Point::x, xmax, xmin, Point::y, ymax, and ymin.

Referenced by vAdjust().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAdjustMode()

static void getAdjustMode ( Agraph_t g,
const char *  s,
adjust_data dp 
)
static

Definition at line 831 of file adjust.c.

References adjustMode, agwarningf(), AM_PRISM, lookup_t::attrib, mapbool(), mapBool(), lookup_t::mode, adjust_data::mode, NULL, lookup_t::print, adjust_data::print, adjust_data::scaling, setPrismValues(), adjust_data::value, and Verbose.

Referenced by graphAdjustMode(), and removeOverlapAs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSizes()

double * getSizes ( Agraph_t g,
pointf  pad,
int *  n_elabels,
int **  elabels 
)

Definition at line 529 of file adjust.c.

References agfstnode(), agnnodes(), agnxtnode(), gv_calloc(), IS_LNODE, ND_height, ND_id, ND_width, Ndim, pointf_s::x, and pointf_s::y.

Referenced by sfdpLayout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ graphAdjustMode()

void graphAdjustMode ( graph_t G,
adjust_data dp,
char *  dflt 
)

Definition at line 880 of file adjust.c.

References agget(), G, and getAdjustMode().

Referenced by neato_layout(), and sfdp_layout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ increaseBoundBox()

static void increaseBoundBox ( state_t st)
static

Definition at line 297 of file adjust.c.

References incr, pxmax, pxmin, pymax, pymin, setBoundBox(), Point::x, and Point::y.

Referenced by vAdjust().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeInfo()

static int makeInfo ( Agraph_t graph)
static

Definition at line 120 of file adjust.c.

References agfstnode(), agnnodes(), agnxtnode(), Site::coord, expand_t::doAdd, free(), geominit(), graph(), gv_calloc(), makeAddPoly(), makePoly(), Info_t::n_verts, ND_pos, Info_t::node, nodeInfo, nsites, NULL, Info_t::poly, PS2INCH, Site::refcnt, sepFactor(), Info_t::site, Site::sitenbr, Info_t::verts, expand_t::x, Point::x, expand_t::y, and Point::y.

Referenced by removeOverlapWith().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeMatrix()

SparseMatrix makeMatrix ( Agraph_t g)

Definition at line 559 of file adjust.c.

References A, agfindedgeattr, agfstnode(), agfstout(), aghead, agnedges(), agnnodes(), agnxtnode(), agnxtout(), agxget(), free(), gv_calloc(), I, MATRIX_TYPE_REAL, ND_id, nedges, NULL, row, and SparseMatrix_from_coordinate_arrays().

Referenced by sfdpLayout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ newPos()

static void newPos ( const state_t st,
bool  doAll 
)
static

Definition at line 407 of file adjust.c.

References addCorners(), doAll, newpos(), nodeInfo, nsites, and Info_t::overlaps.

Referenced by vAdjust().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ newpos()

static void newpos ( Info_t ip)
static

Definition at line 330 of file adjust.c.

References areaOf(), centroidOf(), Site::coord, Info_t::n_verts, Info_t::site, Info_t::verts, Point::x, and Point::y.

Referenced by constrainX(), constrainY(), and newPos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nextOne()

static Site * nextOne ( void *  state)
static

Definition at line 219 of file adjust.c.

References state_t::endSite, state_t::nextSite, and NULL.

Referenced by vAdjust().

Here is the caller graph for this function:

◆ normalize()

int normalize ( graph_t g)

Definition at line 739 of file adjust.c.

References agfstnode(), agfstout(), aghead, agnxtnode(), agtail, angleSet(), ND_pos, NULL, pointf_s::x, and pointf_s::y.

Referenced by dot_splines_(), layout(), and removeOverlapWith().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseFactor()

static int parseFactor ( char *  s,
expand_t pp,
double  sepfact,
double  dflt 
)
static

Definition at line 1032 of file adjust.c.

References expand_t::doAdd, gv_isspace(), expand_t::x, and expand_t::y.

Referenced by esepFactor(), and sepFactor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeOverlapAs()

int removeOverlapAs ( graph_t G,
char *  flag 
)

Definition at line 1009 of file adjust.c.

References agnnodes(), G, getAdjustMode(), and removeOverlapWith().

Referenced by adjustNodes(), and fdp_xLayout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeOverlapWith()

int removeOverlapWith ( graph_t G,
adjust_data am 
)

Definition at line 916 of file adjust.c.

References agnameof(), agnnodes(), agwarningf(), AM_COMPRESS, AM_IPSEP, AM_NONE, AM_NSCALE, AM_ORTHO, AM_ORTHO_YX, AM_ORTHOXY, AM_ORTHOYX, AM_PORTHO, AM_PORTHO_YX, AM_PORTHOXY, AM_PORTHOYX, AM_PRISM, AM_PUSH, AM_PUSHPULL, AM_SCALE, AM_SCALEXY, AM_VOR, AM_VPSC, cAdjust(), chkBoundBox(), fdpAdjust(), free(), freeNodes(), G, makeInfo(), adjust_data::mode, normalize(), adjust_data::print, sAdjust(), scAdjust(), simpleScale(), state_t::sites, updateGraph(), vAdjust(), and Verbose.

Referenced by neato_layout(), removeOverlapAs(), and sfdp_layout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rePos()

static void rePos ( void  )
static

Definition at line 479 of file adjust.c.

References Site::coord, incr, nodeInfo, nsites, Info_t::site, Point::x, and Point::y.

Referenced by sAdjust().

Here is the caller graph for this function:

◆ rmEquality()

static void rmEquality ( state_t st)
static

Definition at line 228 of file adjust.c.

References cnt(), Site::coord, state_t::endSite, nodeInfo, state_t::sites, sortSites(), and Point::x.

Referenced by sAdjust(), and vAdjust().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sAdjust()

static int sAdjust ( state_t st)
static

Definition at line 489 of file adjust.c.

References cnt(), countOverlap(), rePos(), rmEquality(), and Verbose.

Referenced by removeOverlapWith().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scomp()

static int scomp ( const void *  S1,
const void *  S2 
)
static

Definition at line 164 of file adjust.c.

References Site::coord, s1(), Point::x, and Point::y.

Referenced by sortSites().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sepFactor()

expand_t sepFactor ( graph_t g)

Definition at line 1069 of file adjust.c.

References agget(), DFLT_MARGIN, expand_t::doAdd, parseFactor(), SEPFACT, Verbose, expand_t::x, and expand_t::y.

Referenced by cAdjust(), compoundEdges(), majorization(), makeInfo(), scAdjust(), sfdp_layout(), and x_layout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBoundBox()

static void setBoundBox ( state_t st,
Point ll,
Point ur 
)
static

Definition at line 55 of file adjust.c.

References state_t::ne, state_t::nw, pxmax, pxmin, pymax, pymin, state_t::se, state_t::sw, Point::x, and Point::y.

Referenced by chkBoundBox(), and increaseBoundBox().

Here is the caller graph for this function:

◆ setPrismValues()

static void setPrismValues ( Agraph_t g,
const char *  s,
adjust_data dp 
)
static

Definition at line 820 of file adjust.c.

References agfindgraphattr, late_double(), adjust_data::scaling, and adjust_data::value.

Referenced by getAdjustMode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ simpleScale()

static int simpleScale ( graph_t g)
static

Definition at line 887 of file adjust.c.

References agfstnode(), agget(), agnxtnode(), ISZERO, ND_pos, Verbose, pointf_s::x, and pointf_s::y.

Referenced by removeOverlapWith().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sortSites()

static void sortSites ( state_t st)
static

Definition at line 180 of file adjust.c.

References state_t::endSite, gv_calloc(), Info_t::n_verts, state_t::nextSite, nodeInfo, nsites, NULL, Site::refcnt, scomp(), Info_t::site, state_t::sites, and Info_t::verts.

Referenced by geomUpdate(), and rmEquality().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateGraph()

static void updateGraph ( void  )
static

Definition at line 515 of file adjust.c.

References Site::coord, ND_pos, Info_t::node, nodeInfo, nsites, Info_t::site, Point::x, and Point::y.

Referenced by removeOverlapWith().

Here is the caller graph for this function:

◆ vAdjust()

static int vAdjust ( state_t st)
static

Definition at line 429 of file adjust.c.

References cleanup(), cnt(), countOverlap(), doAll, geomUpdate(), increaseBoundBox(), newPos(), nextOne(), rmEquality(), Verbose, and voronoi().

Referenced by removeOverlapWith().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ adjustMode

const lookup_t adjustMode[]
static
Initial value:
= {
{AM_NONE, "", "none"},
{AM_VOR, "voronoi", "Voronoi"},
{AM_NSCALE, "scale", "scaling"},
{AM_COMPRESS, "compress", "compress"},
{AM_VPSC, "vpsc", "vpsc"},
{AM_IPSEP, "ipsep", "ipsep"},
{AM_SCALE, "oscale", "old scaling"},
{AM_SCALEXY, "scalexy", "x and y scaling"},
{AM_ORTHO, "ortho", "orthogonal constraints"},
{AM_ORTHO_YX, "ortho_yx", "orthogonal constraints"},
{AM_ORTHOXY, "orthoxy", "xy orthogonal constraints"},
{AM_ORTHOYX, "orthoyx", "yx orthogonal constraints"},
{AM_PORTHO, "portho", "pseudo-orthogonal constraints"},
{AM_PORTHO_YX, "portho_yx", "pseudo-orthogonal constraints"},
{AM_PORTHOXY, "porthoxy", "xy pseudo-orthogonal constraints"},
{AM_PORTHOYX, "porthoyx", "yx pseudo-orthogonal constraints"},
{AM_PRISM, "prism", 0},
{0}
}
@ AM_PORTHOYX
Definition adjust.h:27
@ AM_NONE
Definition adjust.h:24
@ AM_VPSC
Definition adjust.h:28
@ AM_PORTHO
Definition adjust.h:27
@ AM_ORTHO_YX
Definition adjust.h:26
@ AM_ORTHO
Definition adjust.h:26
@ AM_PORTHO_YX
Definition adjust.h:27
@ AM_NSCALE
Definition adjust.h:25
@ AM_SCALE
Definition adjust.h:25
@ AM_SCALEXY
Definition adjust.h:25
@ AM_IPSEP
Definition adjust.h:28
@ AM_ORTHOYX
Definition adjust.h:26
@ AM_PRISM
Definition adjust.h:28
@ AM_VOR
Definition adjust.h:24
@ AM_ORTHOXY
Definition adjust.h:26
@ AM_PORTHOXY
Definition adjust.h:27
@ AM_COMPRESS
Definition adjust.h:27

Definition at line 793 of file adjust.c.

Referenced by getAdjustMode().

◆ incr

const double incr = 0.05
static

Definition at line 44 of file adjust.c.

Referenced by increaseBoundBox(), and rePos().