Graphviz 12.0.1~dev.20240715.2254
Loading...
Searching...
No Matches
utils.c File Reference
#include <common/render.h>
#include <cgraph/alloc.h>
#include <cgraph/agxbuf.h>
#include <cgraph/gv_ctype.h>
#include <cgraph/gv_math.h>
#include <cgraph/strview.h>
#include <cgraph/tokenize.h>
#include <common/htmltable.h>
#include <common/entities.h>
#include <limits.h>
#include <math.h>
#include <gvc/gvc.h>
#include <cgraph/startswith.h>
#include <cgraph/strcasecmp.h>
#include <cgraph/streq.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <unistd.h>
Include dependency graph for utils.c:

Go to the source code of this file.

Data Structures

struct  fontinfo
 
struct  item
 
struct  cl_edge_t
 
struct  clust_t
 

Macros

#define W_DEGREE   5
 
#define PATHSEP   ":"
 
#define MAXENTLEN   8
 

Functions

int late_int (void *obj, attrsym_t *attr, int defaultValue, int minimum)
 
double late_double (void *obj, attrsym_t *attr, double defaultValue, double minimum)
 
double get_inputscale (graph_t *g)
 
char * late_string (void *obj, attrsym_t *attr, char *defaultValue)
 
char * late_nnstring (void *obj, attrsym_t *attr, char *defaultValue)
 
bool late_bool (void *obj, attrsym_t *attr, bool defaultValue)
 
node_tUF_find (node_t *n)
 
node_tUF_union (node_t *u, node_t *v)
 
void UF_singleton (node_t *u)
 
void UF_setname (node_t *u, node_t *v)
 
pointf coord (node_t *n)
 
pointf Bezier (pointf *V, double t, pointf *Left, pointf *Right)
 
static strview_tmkDirlist (const char *list)
 
static char * findPath (const strview_t *dirs, const char *str)
 
const char * safefile (const char *filename)
 
int maptoken (char *p, char **name, int *val)
 
bool mapBool (const char *p, bool defaultValue)
 
bool mapbool (const char *p)
 
pointf dotneato_closest (splines *spl, pointf pt)
 
void gvToggle (int s)
 
int test_toggle (void)
 
void common_init_node (node_t *n)
 
static void initFontEdgeAttr (edge_t *e, struct fontinfo *fi)
 
static void initFontLabelEdgeAttr (edge_t *e, struct fontinfo *fi, struct fontinfo *lfi)
 
static bool noClip (edge_t *e, attrsym_t *sym)
 Return true if head/tail end of edge should not be clipped to node.
 
static port chkPort (port(*pf)(node_t *, char *, char *), node_t *n, char *s)
 
void common_init_edge (edge_t *e)
 
static boxf addLabelBB (boxf bb, textlabel_t *lp, bool flipxy)
 
boxf polyBB (polygon_t *poly)
 
void updateBB (graph_t *g, textlabel_t *lp)
 
void compute_bb (graph_t *g)
 
bool is_a_cluster (Agraph_t *g)
 
Agsym_tsetAttr (graph_t *g, void *obj, char *name, char *value, Agsym_t *ap)
 
static node_tclustNode (node_t *n, graph_t *cg, agxbuf *xb, graph_t *clg)
 
static int cmpItem (void *pp1, void *pp2)
 
static void * newItem (item *objp, Dtdisc_t *disc)
 
static edge_tcloneEdge (edge_t *e, node_t *ct, node_t *ch)
 Make a copy of e in e's graph but using ct and ch as nodes.
 
static void insertEdge (Dt_t *map, void *t, void *h, edge_t *e)
 
static itemmapEdge (Dt_t *map, edge_t *e)
 Check if we already have cluster edge corresponding to t->h, and return it.
 
static graph_tmapc (Dt_t *cmap, node_t *n)
 
static int checkCompound (edge_t *e, graph_t *clg, agxbuf *xb, Dt_t *map, Dt_t *cmap)
 
static int num_clust_edges (graph_t *g)
 
void processClusterEdges (graph_t *g)
 
static node_tmapN (node_t *n, graph_t *clg)
 
static void undoCompound (edge_t *e, graph_t *clg)
 
void undoClusterEdges (graph_t *g)
 
attrsym_tsafe_dcl (graph_t *g, int obj_kind, char *name, char *defaultValue)
 
static int comp_entities (const void *e1, const void *e2)
 
char * scanEntity (char *t, agxbuf *xb)
 
static int htmlEntity (char **s)
 
static unsigned char cvtAndAppend (unsigned char c, agxbuf *xb)
 
char * htmlEntityUTF8 (char *s, graph_t *g)
 
char * latin1ToUTF8 (char *s)
 Converts string from Latin1 encoding to utf8. Also translates HTML entities.
 
char * utf8ToLatin1 (char *s)
 
bool overlap_node (node_t *n, boxf b)
 
bool overlap_label (textlabel_t *lp, boxf b)
 
static bool overlap_arrow (pointf p, pointf u, double scale, boxf b)
 
static bool overlap_bezier (bezier bz, boxf b)
 
bool overlap_edge (edge_t *e, boxf b)
 
static int edgeType (const char *s, int defaultValue)
 Convert string to edge type.
 
void setEdgeType (graph_t *g, int defaultValue)
 
void get_gradient_points (pointf *A, pointf *G, size_t n, double angle, int flags)
 
void gv_free_splines (edge_t *e)
 
void gv_cleanup_edge (edge_t *e)
 
void gv_cleanup_node (node_t *n)
 
void gv_nodesize (node_t *n, bool flip)
 
double drand48 (void)
 
static void fillMap (Agraph_t *g, Dt_t *map)
 
Dt_tmkClustMap (Agraph_t *g)
 
Agraph_tfindCluster (Dt_t *map, char *name)
 

Variables

static int Tflag
 
static Dtdisc_t mapDisc
 
static Dtdisc_t strDisc
 

Macro Definition Documentation

◆ MAXENTLEN

#define MAXENTLEN   8

Definition at line 1081 of file utils.c.

◆ PATHSEP

#define PATHSEP   ":"

Definition at line 232 of file utils.c.

◆ W_DEGREE

#define W_DEGREE   5

Definition at line 161 of file utils.c.

Function Documentation

◆ addLabelBB()

static boxf addLabelBB ( boxf  bb,
textlabel_t lp,
bool  flipxy 
)
static

Definition at line 565 of file utils.c.

References textlabel_t::dimen, boxf::LL, textlabel_t::pos, boxf::UR, pointf_s::x, and pointf_s::y.

Referenced by compute_bb(), and updateBB().

Here is the caller graph for this function:

◆ Bezier()

pointf Bezier ( pointf V,
double  t,
pointf Left,
pointf Right 
)

Definition at line 169 of file utils.c.

References NULL, V, W_DEGREE, pointf_s::x, and pointf_s::y.

Referenced by approx_bezier(), arrow_type_curve(), bezier_clip(), dotneato_closest(), fig_bezier(), findHorizontal(), findVertical(), gdgen_bezier(), pathtolines(), pic_bezier(), place_portlabel(), splineIntersectf(), splitBSpline(), and update_bb_bz().

Here is the caller graph for this function:

◆ checkCompound()

static int checkCompound ( edge_t e,
graph_t clg,
agxbuf xb,
Dt_t map,
Dt_t cmap 
)
static

Definition at line 852 of file utils.c.

References agcontains(), aghead, agnameof(), agtail, agwarningf(), cloneEdge(), clustNode(), item::h, insertEdge(), IS_CLUST_NODE, mapc(), mapEdge(), and item::t.

Referenced by processClusterEdges().

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

◆ chkPort()

static port chkPort ( port(*)(node_t *, char *, char *)  pf,
node_t n,
char *  s 
)
static

Definition at line 485 of file utils.c.

References port::name, and NULL.

Referenced by common_init_edge().

Here is the caller graph for this function:

◆ cloneEdge()

static edge_t * cloneEdge ( edge_t e,
node_t ct,
node_t ch 
)
static

Definition at line 791 of file utils.c.

References agbindrec(), agcopyattr(), agedge(), agraphof(), ED_compound, and NULL.

Referenced by checkCompound(), and undoCompound().

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

◆ clustNode()

static node_t * clustNode ( node_t n,
graph_t cg,
agxbuf xb,
graph_t clg 
)
static

Generate a special cluster node representing the end node of an edge to the cluster cg. n is a node whose name is the same as the cluster cg. clg is the subgraph of all of the original nodes, which will be deleted later.

Definition at line 725 of file utils.c.

References agbindrec(), agnameof(), agnode(), agraphof(), agroot(), agsubnode(), agxbprint(), agxbuse(), cg(), N_label, N_shape, N_style, SET_CLUST_NODE, and setAttr().

Referenced by checkCompound().

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

◆ cmpItem()

static int cmpItem ( void *  pp1,
void *  pp2 
)
static

Definition at line 755 of file utils.c.

◆ common_init_edge()

void common_init_edge ( edge_t e)

Definition at line 505 of file utils.c.

References agget(), aghead, aghtmlstr(), agraphof(), agtail, agxget(), chkPort(), E_headclip, E_headlabel, E_label, E_label_float, E_tailclip, E_taillabel, E_xlabel, ED_head_label, ED_head_port, ED_label, ED_label_ontop, ED_tail_label, ED_tail_port, ED_xlabel, EDGE_LABEL, EDGE_XLABEL, fontinfo::fontcolor, fontinfo::fontname, fontinfo::fontsize, GD_has_labels, HEAD_ID, HEAD_LABEL, initFontEdgeAttr(), initFontLabelEdgeAttr(), late_string(), LT_HTML, LT_NONE, make_label(), mapbool(), ND_has_port, ND_shape, noClip(), NULL, str, TAIL_ID, and TAIL_LABEL.

Referenced by circular_init_edge(), cluster_init_graph(), dot_init_edge(), init_edge(), init_node_edge(), neato_init_edge(), sfdp_init_edge(), and twopi_init_edge().

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

◆ common_init_node()

void common_init_node ( node_t n)

Definition at line 422 of file utils.c.

References aghtmlstr(), agraphof(), agxget(), bind_shape(), DEFAULT_COLOR, DEFAULT_FONTNAME, DEFAULT_FONTSIZE, DEFAULT_NODEHEIGHT, DEFAULT_NODESHAPE, DEFAULT_NODEWIDTH, fontinfo::fontcolor, fontinfo::fontname, fontinfo::fontsize, GD_has_labels, imin(), late_double(), late_int(), late_nnstring(), LT_HTML, LT_NONE, LT_RECD, make_label(), MIN_FONTSIZE, MIN_NODEHEIGHT, MIN_NODEWIDTH, N_fontcolor, N_fontname, N_fontsize, N_height, N_label, N_shape, N_showboxes, N_width, N_xlabel, ND_height, ND_label, ND_shape, ND_showboxes, ND_width, ND_xlabel, NODE_XLABEL, SH_RECORD, shapeOf(), and str.

Referenced by dot_init_node(), finishNode(), init_node(), and neato_init_node().

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

◆ comp_entities()

static int comp_entities ( const void *  e1,
const void *  e2 
)
static

Definition at line 1077 of file utils.c.

Referenced by htmlEntity(), and scanEntity().

Here is the caller graph for this function:

◆ compute_bb()

void compute_bb ( graph_t g)

Compute bounding box of g using nodes, splines, and clusters. Assumes bb of clusters already computed. store in GD_bb.

Definition at line 629 of file utils.c.

References add_pointf(), addLabelBB(), AGDATA, agfstnode(), agfstout(), agnnodes(), agnxtnode(), agnxtout(), B2BF, coord(), ED_head_label, ED_label, ED_spl, ED_tail_label, ED_xlabel, EXPANDBB, EXPANDBP, GD_bb, GD_clust, GD_flip, GD_label, GD_n_cluster, boxf::LL, ND_xlabel, ND_xsize, ND_ysize, sub_pointf(), boxf::UR, pointf_s::x, and pointf_s::y.

Referenced by doEdges(), init_nop(), layout(), neato_layout(), packSubgraphs(), polyGraphs(), putGraphs(), and spline_edges().

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

◆ coord()

pointf coord ( node_t n)

Definition at line 151 of file utils.c.

References ND_pos, POINTS_PER_INCH, pointf_s::x, and pointf_s::y.

Referenced by average_edge_length(), compute_bb(), emit_begin_node(), fillEdge(), gen_fields(), genPoly(), node_data_new(), QuadTree_add(), QuadTree_add_internal(), QuadTree_get_nearest_internal(), QuadTree_get_quadrant(), QuadTree_get_supernodes_internal(), QuadTree_new_from_point_list(), QuadTree_print_internal(), and right_of().

Here is the caller graph for this function:

◆ cvtAndAppend()

static unsigned char cvtAndAppend ( unsigned char  c,
agxbuf xb 
)
static

Definition at line 1178 of file utils.c.

References agxbputc(), free(), latin1ToUTF8(), and len().

Referenced by htmlEntityUTF8().

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

◆ dotneato_closest()

pointf dotneato_closest ( splines spl,
pointf  pt 
)

Definition at line 341 of file utils.c.

References Bezier(), DIST2, bezier::list, splines::list, NULL, bezier::size, splines::size, SIZE_MAX, pointf_s::x, and pointf_s::y.

Referenced by edgeMidpoint(), and emit_attachment().

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

◆ drand48()

double drand48 ( void  )

Definition at line 1570 of file utils.c.

Referenced by eval(), generateRandomOrdering(), initLayout(), initPositions(), jitter_d(), move_node(), randompos(), and stress_majorization_kD_mkernel().

Here is the caller graph for this function:

◆ edgeType()

static int edgeType ( const char *  s,
int  defaultValue 
)
static

Definition at line 1394 of file utils.c.

References agwarningf(), EDGETYPE_COMPOUND, EDGETYPE_CURVED, EDGETYPE_LINE, EDGETYPE_NONE, EDGETYPE_ORTHO, EDGETYPE_PLINE, EDGETYPE_SPLINE, and NULL.

Referenced by setEdgeType().

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

◆ fillMap()

static void fillMap ( Agraph_t g,
Dt_t map 
)
static

Definition at line 1591 of file utils.c.

References agnameof(), agwarningf(), clust_t::clp, dtinsert, dtmatch, fillMap(), GD_clust, GD_n_cluster, gv_alloc(), and clust_t::name.

Referenced by fillMap(), and mkClustMap().

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

◆ findCluster()

Agraph_t * findCluster ( Dt_t map,
char *  name 
)

Definition at line 1622 of file utils.c.

References clust_t::clp, dtmatch, and NULL.

Referenced by getCluster(), and mapc().

Here is the caller graph for this function:

◆ findPath()

static char * findPath ( const strview_t dirs,
const char *  str 
)
static

Definition at line 247 of file utils.c.

References agxbprint(), agxbuse(), DIRSEP, NULL, agxbuf::size, and str.

Referenced by safefile().

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

◆ get_gradient_points()

void get_gradient_points ( pointf A,
pointf G,
size_t  n,
double  angle,
int  flags 
)

Evaluates the extreme points of an ellipse or polygon Determines the point at the center of the extreme points If isRadial is true,sets the inner radius to half the distance to the min point; else uses the angle parameter to identify two points on a line that defines the gradient direction By default, this assumes a left-hand coordinate system (for svg); if RHS = 2 flag is set, use standard coordinate system.

Definition at line 1466 of file utils.c.

References A, center(), flags, G, MAX, MIN, point::x, pointf_s::x, point::y, and pointf_s::y.

Referenced by cairo_gradient_fill(), svg_gradstyle(), and xdot_gradient_fillcolor().

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

◆ get_inputscale()

double get_inputscale ( graph_t g)

Return value for PSinputscale. If this is > 0, it has been set on the command line and this value is used. Otherwise, we check the graph's inputscale attribute. If this is not set or has a bad value, we return -1. If the value is 0, we return the default. Otherwise, we return the value. Set but negative values are treated like 0.

Definition at line 71 of file utils.c.

References agfindgraphattr, is_exactly_zero(), late_double(), POINTS_PER_INCH, and PSinputscale.

Referenced by fdp_layout(), and neato_layout().

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

◆ gv_cleanup_edge()

void gv_cleanup_edge ( edge_t e)

Definition at line 1533 of file utils.c.

References agdelrec(), ED_head_label, ED_label, ED_path, ED_tail_label, ED_xlabel, free(), free_label(), gv_free_splines(), and ps.

Referenced by circo_cleanup(), dot_cleanup(), fdp_cleanup(), neato_cleanup(), osage_cleanup(), patchwork_cleanup(), sfdp_cleanup(), twopi_cleanup(), and undoCompound().

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

◆ gv_cleanup_node()

void gv_cleanup_node ( node_t n)

Definition at line 1545 of file utils.c.

References agdelrec(), free(), free_label(), ND_label, ND_pos, ND_shape, and ND_xlabel.

Referenced by circo_cleanup(), fdp_cleanup(), neato_cleanup(), osage_cleanup(), patchwork_cleanup(), sfdp_cleanup(), twopi_cleanup(), and undoClusterEdges().

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

◆ gv_free_splines()

void gv_free_splines ( edge_t e)

Definition at line 1523 of file utils.c.

References ED_spl, free(), and NULL.

Referenced by freeEdgeInfo(), gv_cleanup_edge(), and user_spline().

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

◆ gv_nodesize()

void gv_nodesize ( node_t n,
bool  flip 
)

Definition at line 1556 of file utils.c.

References INCH2PS, ND_height, ND_ht, ND_lw, ND_rw, and ND_width.

Referenced by dot_init_node(), init_node(), neato_init_node(), translate_drawing(), and walkTree().

Here is the caller graph for this function:

◆ htmlEntity()

static int htmlEntity ( char **  s)
static

Check for an HTML entity for a special character. Assume *s points to first byte after '&'. If successful, return the corresponding value and update s to point after the terminating ';'. On failure, return 0 and leave s unchanged.

Definition at line 1113 of file utils.c.

References comp_entities(), entities, ENTITY_NAME_LENGTH_MAX, NR_OF_ENTITIES, str, and entities_s::value.

Referenced by htmlEntityUTF8(), and latin1ToUTF8().

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

◆ htmlEntityUTF8()

char * htmlEntityUTF8 ( char *  s,
graph_t g 
)

substitute html entities like: &#123; and: & with the UTF8 equivalents check for invalid utf8. If found, treat a single byte as Latin-1, convert it to utf8 and warn the user.

Definition at line 1199 of file utils.c.

References agnameof(), agwarningf(), agxbdisown(), agxbputc(), cvtAndAppend(), and htmlEntity().

Referenced by make_html_label(), make_label(), and preprocessTooltip().

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

◆ initFontEdgeAttr()

static void initFontEdgeAttr ( edge_t e,
struct fontinfo fi 
)
static

Definition at line 452 of file utils.c.

References DEFAULT_COLOR, DEFAULT_FONTNAME, DEFAULT_FONTSIZE, E_fontcolor, E_fontname, E_fontsize, fontinfo::fontcolor, fontinfo::fontname, fontinfo::fontsize, late_double(), late_nnstring(), and MIN_FONTSIZE.

Referenced by common_init_edge(), and initFontLabelEdgeAttr().

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

◆ initFontLabelEdgeAttr()

static void initFontLabelEdgeAttr ( edge_t e,
struct fontinfo fi,
struct fontinfo lfi 
)
static

Definition at line 460 of file utils.c.

References E_labelfontcolor, E_labelfontname, E_labelfontsize, fontinfo::fontcolor, fontinfo::fontname, fontinfo::fontsize, initFontEdgeAttr(), late_double(), late_nnstring(), and MIN_FONTSIZE.

Referenced by common_init_edge().

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

◆ insertEdge()

static void insertEdge ( Dt_t map,
void *  t,
void *  h,
edge_t e 
)
static

Definition at line 802 of file utils.c.

References aghead, agtail, dtinsert, item::h, item::p, and item::t.

Referenced by checkCompound().

Here is the caller graph for this function:

◆ is_a_cluster()

bool is_a_cluster ( Agraph_t g)

Definition at line 691 of file utils.c.

References agget(), agnameof(), mapbool(), and Agraph_s::root.

Referenced by cloneSubg(), cntCluster(), compile_clusters(), compile_samerank(), deriveClusters(), is_cluster(), projectG(), and subgInduce().

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

◆ late_bool()

bool late_bool ( void *  obj,
attrsym_t attr,
bool  defaultValue 
)

Definition at line 91 of file utils.c.

References agxget(), mapbool(), and NULL.

Referenced by addXLabels(), find_blocks(), and getAttrBool().

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

◆ late_double()

double late_double ( void *  obj,
attrsym_t attr,
double  defaultValue,
double  minimum 
)

◆ late_int()

int late_int ( void *  obj,
attrsym_t attr,
int  defaultValue,
int  minimum 
)

◆ late_nnstring()

char * late_nnstring ( void *  obj,
attrsym_t attr,
char *  defaultValue 
)

Definition at line 84 of file utils.c.

References late_string().

Referenced by checkStyle(), common_init_node(), do_graph_label(), emit_clusters(), emit_edge_graphics(), findCharset(), findFillDflt(), init_gvc(), initFontEdgeAttr(), initFontLabelEdgeAttr(), isFilled(), penColor(), point_gencode(), poly_gencode(), and write_plain().

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

◆ late_string()

char * late_string ( void *  obj,
attrsym_t attr,
char *  defaultValue 
)

Definition at line 78 of file utils.c.

References agxget().

Referenced by clust_in_layer(), common_init_edge(), do_ordering_for_nodes(), dot_init_edge(), edge_in_layer(), emit_edge(), emit_edge_graphics(), emit_end_edge(), emit_graph(), emit_node(), getAttrStr(), getRankseps(), graph_init(), late_nnstring(), node_in_layer(), ordered_edges(), poly_gencode(), poly_init(), and record_init().

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

◆ latin1ToUTF8()

char * latin1ToUTF8 ( char *  s)

Definition at line 1278 of file utils.c.

References agxbdisown(), agxbputc(), and htmlEntity().

Referenced by cvtAndAppend(), make_html_label(), make_label(), preprocessTooltip(), and stoj().

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

◆ mapbool()

bool mapbool ( const char *  p)

Definition at line 336 of file utils.c.

References mapBool().

Referenced by angleSet(), circularLayout(), common_init_edge(), dot_mincross(), dot_rank(), dotLayout(), emit_begin_edge(), emit_end_edge(), findRootNode(), gdgen_begin_page(), get_imagescale(), getAdjustMode(), graph_init(), init_nop(), initialPositions(), is_a_cluster(), is_a_strong_cluster(), is_nonconstraint(), late_bool(), majorization(), neato_layout(), noClip(), nonconstraint_edge(), poly_init(), record_init(), tuneControl(), user_pos(), and visible().

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

◆ mapBool()

bool mapBool ( const char *  p,
bool  defaultValue 
)

Definition at line 320 of file utils.c.

References gv_isdigit().

Referenced by getAdjustMode(), mapbool(), and tuneControl().

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

◆ mapc()

static graph_t * mapc ( Dt_t cmap,
node_t n 
)
static

If endpoint names a cluster, mark for temporary deletion and create special node and insert into cluster. Then clone the edge. Real edge will be deleted when we delete the original node. Invariant: new edge has same sense as old. That is, given t->h with t and h mapped to ct and ch, the new edge is ct->ch.

In the current model, we create a cluster node for each cluster edge between the cluster and some other node or cluster, treating the cluster node as a port on the cluster. This should help with better routing to avoid edge crossings. At present, this is not implemented, so we could use a simpler model in which we create a single cluster node for each cluster used in a cluster edge.

Return 1 if cluster edge is created.

Definition at line 844 of file utils.c.

References agnameof(), findCluster(), NULL, and startswith().

Referenced by checkCompound().

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

◆ mapEdge()

static item * mapEdge ( Dt_t map,
edge_t e 
)
static

Definition at line 820 of file utils.c.

References aghead, agtail, dtmatch, and key.

Referenced by checkCompound().

Here is the caller graph for this function:

◆ mapN()

static node_t * mapN ( node_t n,
graph_t clg 
)
static

Convert cluster nodes back to ordinary nodes If n is already ordinary, return it. Otherwise, we know node's name is "__i:xxx" where i is some number and xxx is the nodes's original name. Create new node of name xxx if it doesn't exist and add n to clg for later deletion.

Definition at line 978 of file utils.c.

References agbindrec(), agfindnode, agnameof(), AGNODE, agnode(), agnxtattr(), agraphof(), agsubnode(), agxget(), agxset(), Agsym_s::defval, IS_CLUST_NODE, NULL, and SET_CLUST_NODE.

Referenced by undoCompound().

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

◆ maptoken()

int maptoken ( char *  p,
char **  name,
int *  val 
)

Definition at line 310 of file utils.c.

References streq().

Referenced by graph_init(), and rank_set_class().

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

◆ mkClustMap()

Dt_t * mkClustMap ( Agraph_t g)

Generates a dictionary mapping cluster names to corresponding cluster. Used with cgraph as the latter does not support a flat namespace of clusters. Assumes G has already built a cluster tree using GD_n_cluster and GD_clust.

Definition at line 1612 of file utils.c.

References dtopen(), Dtoset, fillMap(), and strDisc.

Referenced by dot_compoundEdges(), and processClusterEdges().

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

◆ mkDirlist()

static strview_t * mkDirlist ( const char *  list)
static

Definition at line 235 of file utils.c.

References cnt(), gv_calloc(), gv_recalloc(), PATHSEP, tok(), tok_end(), tok_get(), and tok_next().

Referenced by safefile().

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

◆ newItem()

static void * newItem ( item objp,
Dtdisc_t disc 
)
static

Definition at line 769 of file utils.c.

References gv_alloc(), item::h, item::p, and item::t.

Here is the call graph for this function:

◆ noClip()

static bool noClip ( edge_t e,
attrsym_t sym 
)
static

Definition at line 471 of file utils.c.

References agxget(), mapbool(), and str.

Referenced by common_init_edge().

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

◆ num_clust_edges()

static int num_clust_edges ( graph_t g)
static

Definition at line 922 of file utils.c.

References HAS_CLUST_EDGE, and cl_edge_t::n_cluster_edges.

Referenced by undoClusterEdges().

Here is the caller graph for this function:

◆ overlap_arrow()

static bool overlap_arrow ( pointf  p,
pointf  u,
double  scale,
boxf  b 
)
static

Definition at line 1350 of file utils.c.

References arrow_bb(), OVERLAP, and scale().

Referenced by overlap_bezier().

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

◆ overlap_bezier()

static bool overlap_bezier ( bezier  bz,
boxf  b 
)
static

Definition at line 1356 of file utils.c.

References bezier::eflag, bezier::ep, lineToBox(), bezier::list, overlap_arrow(), bezier::sflag, bezier::size, and bezier::sp.

Referenced by overlap_edge().

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

◆ overlap_edge()

bool overlap_edge ( edge_t e,
boxf  b 
)

Definition at line 1378 of file utils.c.

References splines::bb, boxf_overlap(), ED_label, ED_spl, splines::list, overlap_bezier(), overlap_label(), and splines::size.

Referenced by gvevent_find_obj().

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

◆ overlap_label()

bool overlap_label ( textlabel_t lp,
boxf  b 
)

Definition at line 1341 of file utils.c.

References add_pointf(), textlabel_t::dimen, boxf::LL, OVERLAP, textlabel_t::pos, sub_pointf(), pointf_s::x, and pointf_s::y.

Referenced by edge_in_box(), and overlap_edge().

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

◆ overlap_node()

bool overlap_node ( node_t n,
boxf  b 
)

Definition at line 1329 of file utils.c.

References boxf::LL, mid_pointf(), inside_t::n, ND_bb, ND_coord, ND_shape, OVERLAP, inside_t::s, sub_pointf(), and boxf::UR.

Referenced by gvevent_find_obj().

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

◆ polyBB()

boxf polyBB ( polygon_t poly)

Compute the bounding box of a polygon. We only need to use the outer periphery.

Definition at line 600 of file utils.c.

References boxf::LL, MAX, MIN, boxf::UR, pointf_s::x, and pointf_s::y.

Referenced by makeObstacle(), and poly_inside().

Here is the caller graph for this function:

◆ processClusterEdges()

void processClusterEdges ( graph_t g)

Look for cluster edges. Replace cluster edge endpoints corresponding to a cluster with special cluster nodes. Delete original nodes. If cluster edges are found, a cl_edge_t record will be attached to the graph, containing the count of such edges.

Definition at line 936 of file utils.c.

References agbindrec(), agclose(), agdelete(), agfstnode(), agfstout(), agnxtnode(), agnxtout(), agsubg(), agxbfree(), checkCompound(), CL_EDGE_TAG, dtclose(), dtopen(), Dtoset, IS_CLUST_NODE, mapDisc, mkClustMap(), and cl_edge_t::n_cluster_edges.

Referenced by fdp_init_node_edge().

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

◆ safe_dcl()

attrsym_t * safe_dcl ( graph_t g,
int  obj_kind,
char *  name,
char *  defaultValue 
)

Find the attribute belonging to graph g for objects like obj with given name. If one does not exist, create it with the default value defaultValue.

Definition at line 1070 of file utils.c.

References agattr(), and NULL.

Referenced by attach_attrs_and_arrows(), xdot_begin_graph(), and xdot_end_graph().

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

◆ safefile()

const char * safefile ( const char *  filename)

Definition at line 259 of file utils.c.

References agwarningf(), DIRSEP, findPath(), free(), Gvfilepath, Gvimagepath, HTTPServerEnVar, mkDirlist(), NULL, onetime, and str.

Referenced by bind_shape(), cat_libfile(), epsf_init(), and gvusershape_file_access().

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

◆ scanEntity()

char * scanEntity ( char *  t,
agxbuf xb 
)

Scan non-numeric entity, convert to &#...; form and store in xbuf. t points to first char after '&'. Return after final semicolon. If unknown, we return t and let libexpat flag the error.

Definition at line 1087 of file utils.c.

References agxbprint(), agxbputc(), comp_entities(), entities, len(), MAXENTLEN, NR_OF_ENTITIES, and entities_s::value.

Here is the call graph for this function:

◆ setAttr()

Agsym_t * setAttr ( graph_t g,
void *  obj,
char *  name,
char *  value,
Agsym_t ap 
)

Sets object's name attribute to the given value. Creates the attribute if not already set.

Definition at line 700 of file utils.c.

References agattr(), AGEDGE, AGNODE, agobjkind(), AGRAPH, agxset(), and NULL.

Referenced by clustNode().

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

◆ setEdgeType()

void setEdgeType ( graph_t g,
int  defaultValue 
)

Sets graph's edge type based on the "splines" attribute. If the attribute is not defined, use defaultValue. If the attribute is "", use NONE. If attribute value matches (case indepedent), use match. ortho => EDGETYPE_ORTHO none => EDGETYPE_NONE line => EDGETYPE_LINE polyline => EDGETYPE_PLINE spline => EDGETYPE_SPLINE If attribute is boolean, true means EDGETYPE_SPLINE, false means EDGETYPE_LINE. Else warn and use default.

Definition at line 1443 of file utils.c.

References agget(), edgeType(), EDGETYPE_NONE, and GD_flags.

Referenced by circo_init_graph(), cluster_init_graph(), dotLayout(), fdp_init_graph(), make_flat_adj_edges(), neato_init_graph(), neato_layout(), patchwork_init_graph(), sfdp_init_graph(), sfdp_layout(), and twopi_init_graph().

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

◆ test_toggle()

int test_toggle ( void  )

Definition at line 411 of file utils.c.

References Tflag.

Referenced by move_node().

Here is the caller graph for this function:

◆ UF_find()

node_t * UF_find ( node_t n)

Definition at line 99 of file utils.c.

References ND_UF_parent.

Referenced by class1(), class2(), decompose(), expand_ranksets(), interclust1(), leader_of(), minmax_edges(), minmax_edges2(), search_component(), UF_setname(), and UF_union().

Here is the caller graph for this function:

◆ UF_setname()

void UF_setname ( node_t u,
node_t v 
)

Definition at line 144 of file utils.c.

References ND_UF_parent, ND_UF_size, and UF_find().

Referenced by mark_clusters().

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

◆ UF_singleton()

void UF_singleton ( node_t u)

Definition at line 137 of file utils.c.

References ND_ranktype, ND_UF_parent, ND_UF_size, NORMAL, and NULL.

Referenced by expand_ranksets(), and mark_clusters().

Here is the caller graph for this function:

◆ UF_union()

node_t * UF_union ( node_t u,
node_t v 
)

Definition at line 109 of file utils.c.

References ND_id, ND_UF_parent, ND_UF_size, NULL, and UF_find().

Referenced by cluster_leader(), and collapse_rankset().

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

◆ undoClusterEdges()

void undoClusterEdges ( graph_t g)

Replace cluster nodes with originals. Make sure original has no attributes. Replace original edges. Delete cluster nodes, which will also delete cluster edges.

Definition at line 1035 of file utils.c.

References agbindrec(), agclose(), agdelete(), agfstnode(), agfstout(), agnxtnode(), agnxtout(), agsubg(), ED_compound, free(), gv_calloc(), gv_cleanup_node(), num_clust_edges(), and undoCompound().

Referenced by attach_attrs_and_arrows(), and dot_begin_graph().

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

◆ undoCompound()

static void undoCompound ( edge_t e,
graph_t clg 
)
static

Definition at line 1005 of file utils.c.

References aghead, agtail, cloneEdge(), ED_head_label, ED_label, ED_spl, ED_tail_label, ED_xlabel, gv_cleanup_edge(), mapN(), and NULL.

Referenced by undoClusterEdges().

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

◆ updateBB()

void updateBB ( graph_t g,
textlabel_t lp 
)

Reset graph's bounding box to include bounding box of the given label. Assume the label's position has been set.

Definition at line 620 of file utils.c.

References addLabelBB(), GD_bb, and GD_flip.

Referenced by addXLabels(), dot_splines_(), make_flat_adj_edges(), makePortLabels(), makeSelfArcs(), and setEdgeLabelPos().

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

◆ utf8ToLatin1()

char * utf8ToLatin1 ( char *  s)

Converts string from utf8 encoding to Latin1 Note that it does not attempt to reproduce HTML entities. We assume the input string comes from latin1ToUTF8.

Definition at line 1311 of file utils.c.

References agxbdisown(), and agxbputc().

Referenced by ps_string().

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

Variable Documentation

◆ mapDisc

Dtdisc_t mapDisc
static
Initial value:
= {
.key = offsetof(item, p),
.size = sizeof(2 * sizeof(void *)),
.link = offsetof(item, link),
.makef = (Dtmake_f)newItem,
.freef = free,
.comparf = cmpItem,
}
void *(* Dtmake_f)(void *, Dtdisc_t *)
Definition cdt.h:50
static void * newItem(item *objp, Dtdisc_t *disc)
Definition utils.c:769
static int cmpItem(void *pp1, void *pp2)
Definition utils.c:755
void free(void *)
static void freef(void *ident)
Definition utils.c:748

Definition at line 781 of file utils.c.

Referenced by processClusterEdges().

◆ strDisc

Dtdisc_t strDisc
static
Initial value:
= {
.key = offsetof(clust_t, name),
.size = -1,
.link = offsetof(clust_t, link),
.freef = free,
}

Definition at line 1584 of file utils.c.

Referenced by mkClustMap().

◆ Tflag

int Tflag
static

Definition at line 401 of file utils.c.

Referenced by gvToggle(), and test_toggle().