# FreeBSD Manual Pages

LIBPACK(3) Library Functions Manual LIBPACK(3)NAMElibpack- support for connected componentsSYNOPSIS#include <graphviz/pack.h> typedef enum { l_clust, l_node, l_graph, l_array} pack_mode; typedef struct { float aspect; /* desired aspect ratio */ int sz; /* row/column size size */ unsigned int margin; /* margin left around objects, in points */ int doSplines; /* use splines in constructing graph shape */ pack_mode mode; /* granularity and method */ boolean *fixed; /* fixed[i] == true implies g[i] should not be moved */ packval_t* vals; /* for arrays, sort numbers */ int flags; } pack_info; point* putRects(int ng, boxf* bbs, pack_info* pinfo); int packRects(int ng, boxf* bbs, pack_info* pinfo); point* putGraphs (int, Agraph_t**, Agraph_t*, pack_info*); int packGraphs (int, Agraph_t**, Agraph_t*, pack_info*); int packSubgraphs (int, Agraph_t**, Agraph_t*, pack_info*); pack_mode getPackMode (Agraph_t*, pack_mode dflt); int getPack (Agraph_t*, int, int); int isConnected (Agraph_t*); Agraph_t** ccomps (Agraph_t*, int*, char*); Agraph_t** pccomps (Agraph_t*, int*, char*, boolean*); int nodeInduce (Agraph_t*);DESCRIPTIONlibpacksupports the use of connected components in the context of lay- ing out graphs using othergraphvizlibraries. One set of functions can be used to take a single graph and break it apart into connected components. A complementary set of functions takes a collection of graphs (not necessarily components of a single graph) which have been laid out separately, and packs them together. As this library is meant to be used withlibcommon, it relies on theAgraphinfo_t,Agnodeinfo_tandAgedgeinfo_tused in that library. The specific dependencies are given below in the function descriptions.CreatingcomponentsAgraph_t**ccomps(Agraph_t*g,int*cnt,char*pfx)The functionccompstakes a graphgand returns an array of pointers to subgraphs ofgwhich are its connected components.cntis set to the number of components. Ifpfxis non-NULL, it is used as a prefix for the names of the subgraphs; otherwise, the string ``_cc_'' is used. Note that the subgraphs only contain the relevant nodes, not any corre- sponding edges. Depending on the use, this allows the caller to re- trieve edge information from the root graph. The array returned is obtained frommallocand must be freed by the caller. The function relies on themarkfield inAgnodeinfo_t.Agraph_t**pccomps(Agraph_t*g,int*cnt,char*pfx,boolean*pinned)This is identical toccompsexcept that is puts all pinned nodes in the first component returned. In addition, ifpinnedis non-NULL, it is set to true if pinned nodes are found and false otherwise.intnodeInduce(Agraph_t*g)This function takes a subgraphgand finds all edges in its root graph both of whose endpoints are ing. It returns the number of such edges and, if this edge is not already in the subgraph, it is added.intisConnected(Agraph_t*g)This function returns non-zero if the graphgis connected.Packingcomponentspoint*putGraphs(intng,Agraph_t**gs,Agraph_t*root,pack_infoip)putGraphspacks together a collection of laid out graphs into a single layout which avoids any overlap. It takes as inputnggraphsgs. For each graph, it is assumed that all the nodes have been positioned usingpos, and that thexsizeandysizefields have been set. Ifrootis non-NULL, it is taken as the root graph of the subgraphsgsand is used to find the edges. Otherwise,putGraphsuses the edges found in each graphgs[i]. For the modesl_node,l_clust, andl_graph, the packing is done using the polyomino-based algorithm of Freivalds et al. This allows for a fairly tight packing, in which a convex part of one graph might be in- serted into the concave part of another. The granularity of the poly- ominoes used depends on the value ofip-_mode. If this isl_node, a polyomino is constructed to approximate the nodes and edges. If this isl_clust, the polyomino treats top-level clusters as single rectangles, unioned with the polyominoes for the remaining nodes and edges. If the value isl_graph, the polyomino for a graph is a single rectangle cor- responding to the bounding box of the graph. The model_nodespecifies that the graphs should be packed as an array. Ifip-_doSplinesis true, the function uses the spline information in thesplfield of an edge, if it exists. Otherwise, the algorithm rep- resents an edge as a straight line segment connecting node centers. The parameterip-_marginspecifies a boundary ofmarginpoints to be allowed around each node. It must be non-negative. The parameterip-_fixed, if non-null, should point to an array ofngbooleans. Ifip-_fixed[i]is true, graphgs[i]should be left at its original position. The packing will first first place all of the fixed graphs, then fill in the with the remaining graphs. The function returns an array of points which can be used as the origin of the bounding box of each graph. If the graphs are translated to these positions, none of the graph components will overlap. The array returned is obtained frommallocand must be freed by the caller. If any problem occurs,putGraphsreturns NULL. As a side-effect, at its start,putGraphssets thebbof each graph to reflect its initial lay- out. Note thatputGraphsdoes not do any translation or change the in- put graphs in any other way than setting thebb. This function uses thebbfield inAgraphinfo_t, thepos,xsizeandysizefields innodehinfo_tand thesplfield inAedgeinfo_t.intpackGraphs(intng,Agraph_t**gs,Agraph_t*root,pack_info*ip)This function takesngsubgraphsgsof a root graphrootand callsput-Graphswith the given arguments to generate a packing of the subgraphs. If successful, it then invokes shifts the subgraphs to their new posi- tions. It returns 0 on success.intpackSubgraphs(intng,Agraph_t**gs,Agraph_t*root,pack_info*ip)This function simply callspackGraphswith the given arguments, and then recomputes the bounding box of therootgraph.intpack_graph(intng,Agraph_t**gs,Agraph_t*root,boolean*fixed)usespackSubgraphsto place the individual subgraphs into a single lay- out with the parameters obtained fromgetPackInfo. If successful,dot-neato_postprocessis called on the root graph.point*putRects(intng,boxf*bbs,pack_info*ip)putRectspacks together a collection of rectangles into a single layout which avoids any overlap. It takes as inputngrectanglesbbs. Its behavior and return value are analogous to those ofputGraphs. However, the modesl_nodeandl_clustare illegal. The fieldsfixedanddoSplinesofipare unused.intpackRects(intng,boxf*bbs,pack_info*ip)packRectsis analogous topackGraphs: it callsputRectsand, if this is successful, it translates the rectangles inbbsappropriately.UtilityfunctionsThe library provides several functions which can be used to tailor the packing based on graph attributes.pack_modeparsePackModeInfo(char*p,pack_modedflt,pack_info*pinfo)analyzespas a string representation of pack mode, storing the infor- mation inpinfo. Ifpis "cluster", it returnsl_clust; for "graph", it returnsl_graph; for "node", it returnsl_node; for "array", it re- turnsl_array; for "aspect", it returnsl_aspect; otherwise, it returnsdflt. Related data is also stored inpinfo.pack_modegetPackModeInfo(Agraph_t*g,pack_modedflt,pack_info*pinfo)This function processes the graph's"packmode"attribute, storing the information inpinfo. It returnspinfo-_mode. The attribute is pro- cessed usingparsePackModeInfowithdfltpassed as the default argu- ment.pack_modegetPackMode(Agraph_t*g,pack_modedflt)This function returns apack_modeassociated withg.intgetPack(Agraph_t*g,intnot_def,intdflt)This function queries the graph attribute"pack". If this is defined as a non-negative integer, the integer is returned; if it is defined as "true", the valuedfltis returned; otherwise, the valuenot_defis re- turned.pack_modegetPackInfo(Agraph_t*g,pack_modedflt,intdfltMargin,pack_info*pinfo)This function calls bothgetPackModeInfoandgetPack, storing the in- formation inpinfo.dfltMarginis used for both integer arguments ofgetPack, with the result saved aspinfo-_margin. It returnspinfo-_mode.SEE ALSOdot(1),neato(1),twopi(1),libgraph(3) K. Freivalds et al., "Disconnected Graph Layout and the Polyomino Pack- ing Approach", GD0'01, LNCS 2265, pp. 378-391.BUGSThe packing does not take into account edge or graph labels.AUTHORSEmden Gansner (erg@research.att.com). 04 APRIL 2009 LIBPACK(3)

NAME | SYNOPSIS | DESCRIPTION | SEE ALSO | BUGS | AUTHORS

Want to link to this manual page? Use this URL:

<https://www.freebsd.org/cgi/man.cgi?query=pack&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports>