Graphviz 13.0.0~dev.20241212.1010
Loading...
Searching...
No Matches
pack.c File Reference
#include <assert.h>
#include <common/pointset.h>
#include <common/render.h>
#include <math.h>
#include <pack/pack.h>
#include <stdbool.h>
#include <stddef.h>
#include <util/alloc.h>
#include <util/prisize_t.h>
#include <util/sort.h>
#include <util/startswith.h>
#include <util/streq.h>
Include dependency graph for pack.c:

Go to the source code of this file.

Data Structures

struct  ginfo
 
struct  ainfo
 

Macros

#define C   100 /* Max. avg. polyomino size */
 
#define MOVEPT(p)   ((p).x += dx, (p).y += dy)
 
#define CVAL(v, s)   ((v) >= 0 ? (v) / (s) : (((v) + 1) / (s)) - 1)
 
#define CELL(p, s)   ((p).x = CVAL((p).x, s), (p).y = CVAL((p).y, (s)))
 

Functions

static int GRID (double x, int s)
 given cell size s, how many cells are required by size x?
 
static int computeStep (size_t ng, boxf *bbs, unsigned int margin)
 
static int cmpf (const void *X, const void *Y)
 
static int sgn (int x)
 sgn, as defined in Graphics Gems I, ยง11.8, pp. 99
 
static void fillLine (pointf p, pointf q, PointSet *ps)
 
static void fillEdge (Agedge_t *e, pointf p, PointSet *ps, double dx, double dy, int ssize, bool doS)
 
static void genBox (boxf bb0, ginfo *info, int ssize, unsigned int margin, pointf center, char *s)
 
static int genPoly (Agraph_t *root, Agraph_t *g, ginfo *info, int ssize, pack_info *pinfo, pointf center)
 
static int fits (int x, int y, ginfo *info, PointSet *ps, pointf *place, int step, boxf *bbs)
 
static void placeFixed (ginfo *info, PointSet *ps, pointf *place, pointf center)
 
static void placeGraph (size_t i, ginfo *info, PointSet *ps, pointf *place, int step, unsigned int margin, boxf *bbs)
 
static int ucmpf (const void *X, const void *Y, void *user_values)
 Sort by user values.
 
static int acmpf (const void *X, const void *Y)
 Sort by height + width.
 
static void INC (bool m, size_t *c, size_t *r, size_t nc, size_t nr)
 
static pointfarrayRects (size_t ng, boxf *gs, pack_info *pinfo)
 
static pointfpolyRects (size_t ng, boxf *gs, pack_info *pinfo)
 
static pointfpolyGraphs (size_t ng, Agraph_t **gs, Agraph_t *root, pack_info *pinfo)
 
pointfputGraphs (size_t ng, Agraph_t **gs, Agraph_t *root, pack_info *pinfo)
 
pointfputRects (size_t ng, boxf *bbs, pack_info *pinfo)
 
int packRects (size_t ng, boxf *bbs, pack_info *pinfo)
 
static void shiftEdge (Agedge_t *e, double dx, double dy)
 Translate all of the edge components by the given offset.
 
static void shiftGraph (Agraph_t *g, double dx, double dy)
 
int shiftGraphs (size_t ng, Agraph_t **gs, pointf *pp, Agraph_t *root, bool doSplines)
 
int packGraphs (size_t ng, Agraph_t **gs, Agraph_t *root, pack_info *info)
 
int packSubgraphs (size_t ng, Agraph_t **gs, Agraph_t *root, pack_info *info)
 
int pack_graph (size_t ng, Agraph_t **gs, Agraph_t *root, bool *fixed)
 Pack subgraphs followed by postprocessing.
 
static const char * chkFlags (const char *p, pack_info *pinfo)
 
static const char * mode2Str (pack_mode m)
 
pack_mode parsePackModeInfo (const char *p, pack_mode dflt, pack_info *pinfo)
 
pack_mode getPackModeInfo (Agraph_t *g, pack_mode dflt, pack_info *pinfo)
 
pack_mode getPackMode (Agraph_t *g, pack_mode dflt)
 
int getPack (Agraph_t *g, int not_def, int dflt)
 
pack_mode getPackInfo (Agraph_t *g, pack_mode dflt, int dfltMargin, pack_info *pinfo)
 

Macro Definition Documentation

◆ C

#define C   100 /* Max. avg. polyomino size */

Definition at line 29 of file pack.c.

◆ CELL

#define CELL (   p,
  s 
)    ((p).x = CVAL((p).x, s), (p).y = CVAL((p).y, (s)))

Definition at line 44 of file pack.c.

◆ CVAL

#define CVAL (   v,
  s 
)    ((v) >= 0 ? (v) / (s) : (((v) + 1) / (s)) - 1)

Definition at line 41 of file pack.c.

◆ MOVEPT

#define MOVEPT (   p)    ((p).x += dx, (p).y += dy)

Definition at line 31 of file pack.c.

Function Documentation

◆ acmpf()

static int acmpf ( const void *  X,
const void *  Y 
)
static

Definition at line 566 of file pack.c.

References ainfo::height, ainfo::width, X, and Y.

Referenced by arrayRects().

Here is the caller graph for this function:

◆ arrayRects()

static pointf * arrayRects ( size_t  ng,
boxf gs,
pack_info pinfo 
)
static

Definition at line 601 of file pack.c.

References acmpf(), pack_info::flags, free(), gv_calloc(), gv_sort(), ainfo::height, INC, ainfo::index, boxf::LL, pack_info::margin, PK_BOT_ALIGN, PK_COL_MAJOR, PK_INPUT_ORDER, PK_LEFT_ALIGN, PK_RIGHT_ALIGN, PK_TOP_ALIGN, PRISIZE_T, sinfo, pack_info::sz, ucmpf(), boxf::UR, pack_info::vals, Verbose, ainfo::width, pointf_s::x, and pointf_s::y.

Referenced by putGraphs(), and putRects().

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

◆ chkFlags()

static const char * chkFlags ( const char *  p,
pack_info pinfo 
)
static

Definition at line 1140 of file pack.c.

References pack_info::flags, PK_BOT_ALIGN, PK_COL_MAJOR, PK_INPUT_ORDER, PK_LEFT_ALIGN, PK_RIGHT_ALIGN, PK_TOP_ALIGN, and PK_USER_VALS.

Referenced by parsePackModeInfo().

Here is the caller graph for this function:

◆ cmpf()

static int cmpf ( const void *  X,
const void *  Y 
)
static

Definition at line 100 of file pack.c.

References ginfo::perim, X, and Y.

Referenced by polyGraphs(), and polyRects().

Here is the caller graph for this function:

◆ computeStep()

static int computeStep ( size_t  ng,
boxf bbs,
unsigned int  margin 
)
static

Definition at line 62 of file pack.c.

References C, boxf::LL, boxf::UR, Verbose, pointf_s::x, and pointf_s::y.

Referenced by polyGraphs(), and polyRects().

Here is the caller graph for this function:

◆ fillEdge()

static void fillEdge ( Agedge_t e,
pointf  p,
PointSet ps,
double  dx,
double  dy,
int  ssize,
bool  doS 
)
static

Definition at line 167 of file pack.c.

References aghead, CELL, coord(), ED_spl, bezier::eflag, bezier::ep, fillLine(), bezier::list, MOVEPT, ps, bezier::sflag, bezier::size, and bezier::sp.

Referenced by genPoly().

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

◆ fillLine()

static void fillLine ( pointf  p,
pointf  q,
PointSet ps 
)
static

Definition at line 119 of file pack.c.

References addPS(), dx, dy, ps, ROUND, sgn(), pointf_s::x, and pointf_s::y.

Referenced by fillEdge().

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

◆ fits()

static int fits ( int  x,
int  y,
ginfo info,
PointSet ps,
pointf place,
int  step,
boxf bbs 
)
static

Definition at line 417 of file pack.c.

References inPS(), insertPS(), boxf::LL, ps, Verbose, pointf_s::x, and pointf_s::y.

Referenced by placeGraph().

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

◆ genBox()

static void genBox ( boxf  bb0,
ginfo info,
int  ssize,
unsigned int  margin,
pointf  center,
char *  s 
)
static

Definition at line 224 of file pack.c.

References addPS(), CELL, center(), freePS(), GRID(), boxf::LL, newPS(), pointsOf(), ps, sizeOf(), boxf::UR, Verbose, point::x, pointf_s::x, point::y, and pointf_s::y.

Referenced by polyGraphs(), and polyRects().

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

◆ genPoly()

static int genPoly ( Agraph_t root,
Agraph_t g,
ginfo info,
int  ssize,
pack_info pinfo,
pointf  center 
)
static

Definition at line 273 of file pack.c.

References add_pointf(), addPS(), agfstnode(), agfstout(), aghead, agnameof(), agnnodes(), agnxtnode(), agnxtout(), CELL, center(), coord(), pack_info::doSplines, dx, dy, fillEdge(), free(), freePS(), GD_bb, GD_clust, GD_n_cluster, GRID(), gv_calloc(), l_clust, boxf::LL, pack_info::margin, pack_info::mode, MOVEPT, ND_alg, ND_clust, ND_xsize, ND_ysize, newPS(), pointsOf(), ps, sizeOf(), sub_pointf(), boxf::UR, Verbose, point::x, pointf_s::x, point::y, and pointf_s::y.

Referenced by polyGraphs().

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

◆ getPack()

int getPack ( Agraph_t g,
int  not_def,
int  dflt 
)

Definition at line 1266 of file pack.c.

References agget().

Referenced by compoundEdges(), doDot(), getPackInfo(), and neato_layout().

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

◆ getPackInfo()

pack_mode getPackInfo ( Agraph_t g,
pack_mode  dflt,
int  dfltMargin,
pack_info pinfo 
)

Definition at line 1281 of file pack.c.

References pack_info::doSplines, pack_info::fixed, getPack(), getPackModeInfo(), pack_info::margin, pack_info::mode, NULL, and Verbose.

Referenced by circoLayout(), doDot(), init_info(), layout(), pack_graph(), sfdp_layout(), and twopi_layout().

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

◆ getPackMode()

pack_mode getPackMode ( Agraph_t g,
pack_mode  dflt 
)

Definition at line 1257 of file pack.c.

References getPackModeInfo().

Here is the call graph for this function:

◆ getPackModeInfo()

pack_mode getPackModeInfo ( Agraph_t g,
pack_mode  dflt,
pack_info pinfo 
)

Definition at line 1253 of file pack.c.

References agget(), and parsePackModeInfo().

Referenced by doDot(), getPackInfo(), getPackMode(), and neato_layout().

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

◆ GRID()

static int GRID ( double  x,
int  s 
)
static

Definition at line 34 of file pack.c.

Referenced by genBox(), genPoly(), and placeGraph().

Here is the caller graph for this function:

◆ INC()

static void INC ( bool  m,
size_t *  c,
size_t *  r,
size_t  nc,
size_t  nr 
)
static

step to the next iteration of a matrix cell loop

Parameters
mIs the matrix in row-major order?
c[inout] Column index
r[inout] Row index
ncTotal column count
nrTotal row count

Definition at line 585 of file pack.c.

◆ mode2Str()

static const char * mode2Str ( pack_mode  m)
static

Definition at line 1185 of file pack.c.

References l_array, l_aspect, l_clust, l_graph, l_node, and l_undef.

Referenced by parsePackModeInfo().

Here is the caller graph for this function:

◆ pack_graph()

int pack_graph ( size_t  ng,
Agraph_t **  gs,
Agraph_t root,
bool *  fixed 
)

Definition at line 1127 of file pack.c.

References CL_OFFSET, dotneato_postprocess(), getPackInfo(), l_graph, and packSubgraphs().

Referenced by main().

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

◆ packGraphs()

int packGraphs ( size_t  ng,
Agraph_t **  gs,
Agraph_t root,
pack_info info 
)

Definition at line 1089 of file pack.c.

References free(), putGraphs(), and shiftGraphs().

Referenced by main(), neato_layout(), and packSubgraphs().

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

◆ packRects()

int packRects ( size_t  ng,
boxf bbs,
pack_info pinfo 
)

Definition at line 948 of file pack.c.

References add_pointf(), free(), boxf::LL, putRects(), and boxf::UR.

Here is the call graph for this function:

◆ packSubgraphs()

int packSubgraphs ( size_t  ng,
Agraph_t **  gs,
Agraph_t root,
pack_info info 
)

Definition at line 1104 of file pack.c.

References compute_bb(), EXPANDBB, GD_bb, GD_clust, GD_n_cluster, and packGraphs().

Referenced by circoLayout(), doDot(), pack_graph(), sfdp_layout(), and twopi_layout().

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

◆ parsePackModeInfo()

pack_mode parsePackModeInfo ( const char *  p,
pack_mode  dflt,
pack_info pinfo 
)

Definition at line 1208 of file pack.c.

References pack_info::aspect, chkFlags(), pack_info::flags, l_array, l_aspect, l_clust, l_graph, l_node, pack_info::mode, mode2Str(), NULL, startswith(), streq(), pack_info::sz, pack_info::vals, and Verbose.

Referenced by getPackModeInfo(), and init().

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

◆ placeFixed()

static void placeFixed ( ginfo info,
PointSet ps,
pointf place,
pointf  center 
)
static

Definition at line 456 of file pack.c.

References center(), insertPS(), ps, Verbose, point::x, pointf_s::x, point::y, and pointf_s::y.

Referenced by polyGraphs().

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

◆ placeGraph()

static void placeGraph ( size_t  i,
ginfo info,
PointSet ps,
pointf place,
int  step,
unsigned int  margin,
boxf bbs 
)
static

Definition at line 478 of file pack.c.

References fits(), GRID(), boxf::LL, ps, boxf::UR, pointf_s::x, and pointf_s::y.

Referenced by polyGraphs(), and polyRects().

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

◆ polyGraphs()

static pointf * polyGraphs ( size_t  ng,
Agraph_t **  gs,
Agraph_t root,
pack_info pinfo 
)
static

Definition at line 782 of file pack.c.

References agnameof(), center(), cmpf(), compute_bb(), computeStep(), pack_info::fixed, free(), freePS(), GD_bb, genBox(), genPoly(), gv_calloc(), l_graph, boxf::LL, pack_info::margin, pack_info::mode, newPS(), placeFixed(), placeGraph(), PRISIZE_T, ps, sinfo, boxf::UR, Verbose, point::x, pointf_s::x, point::y, and pointf_s::y.

Referenced by putGraphs().

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

◆ polyRects()

static pointf * polyRects ( size_t  ng,
boxf gs,
pack_info pinfo 
)
static

Definition at line 713 of file pack.c.

References cmpf(), computeStep(), free(), freePS(), genBox(), gv_calloc(), pack_info::margin, newPS(), placeGraph(), PRISIZE_T, ps, sinfo, and Verbose.

Referenced by putRects().

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

◆ putGraphs()

pointf * putGraphs ( size_t  ng,
Agraph_t **  gs,
Agraph_t root,
pack_info pinfo 
)

Definition at line 888 of file pack.c.

References agget(), arrayRects(), compute_bb(), pack_info::flags, free(), GD_bb, gv_calloc(), l_array, l_graph, pack_info::mode, NULL, PK_USER_VALS, polyGraphs(), and pack_info::vals.

Referenced by layout(), and packGraphs().

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

◆ putRects()

pointf * putRects ( size_t  ng,
boxf bbs,
pack_info pinfo 
)

Definition at line 927 of file pack.c.

References arrayRects(), l_array, l_clust, l_graph, l_node, pack_info::mode, NULL, and polyRects().

Referenced by layout(), and packRects().

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

◆ sgn()

static int sgn ( int  x)
static

Definition at line 114 of file pack.c.

Referenced by fillLine(), selfBottom(), selfLeft(), selfRight(), and selfTop().

Here is the caller graph for this function:

◆ shiftEdge()

static void shiftEdge ( Agedge_t e,
double  dx,
double  dy 
)
static

Definition at line 970 of file pack.c.

References ED_head_label, ED_label, ED_spl, ED_tail_label, ED_xlabel, bezier::eflag, bezier::list, MOVEPT, NULL, bezier::sflag, and bezier::size.

Referenced by shiftGraphs().

Here is the caller graph for this function:

◆ shiftGraph()

static void shiftGraph ( Agraph_t g,
double  dx,
double  dy 
)
static

Definition at line 995 of file pack.c.

References dx, dy, GD_bb, GD_clust, GD_label, GD_n_cluster, boxf::LL, MOVEPT, shiftGraph(), boxf::UR, pointf_s::x, and pointf_s::y.

Referenced by shiftGraph(), and shiftGraphs().

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

◆ shiftGraphs()

int shiftGraphs ( size_t  ng,
Agraph_t **  gs,
pointf pp,
Agraph_t root,
bool  doSplines 
)

Definition at line 1037 of file pack.c.

References agfstnode(), agfstout(), agnxtnode(), agnxtout(), dx, dy, MOVEPT, ND_coord, ND_pos, ND_xlabel, PS2INCH, shiftEdge(), shiftGraph(), pointf_s::x, and pointf_s::y.

Referenced by packGraphs().

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

◆ ucmpf()

static int ucmpf ( const void *  X,
const void *  Y,
void *  user_values 
)
static

Definition at line 551 of file pack.c.

References ainfo::index, X, and Y.

Referenced by arrayRects().

Here is the caller graph for this function: