Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
gvpack.cpp File Reference

merge and pack disjoint graphs More...

#include "config.h"
#include <getopt.h>
#include <algorithm>
#include <cassert>
#include <gvc/gvc.h>
#include <cgraph/ingraphs.h>
#include <common/render.h>
#include <common/utils.h>
#include <neatogen/neatoprocs.h>
#include <iostream>
#include <limits>
#include <map>
#include <optional>
#include <pack/pack.h>
#include <set>
#include <stddef.h>
#include <string>
#include <utility>
#include <util/alloc.h>
#include <util/exit.h>
#include <vector>
#include "openFile.h"
Include dependency graph for gvpack.cpp:

Go to the source code of this file.

Data Structures

struct  attr_t
 

Macros

#define NEWNODE(n)   ((node_t*)ND_alg(n))
 
#define MARK(e)   (ED_alg(e) = e)
 
#define MARKED(e)   (ED_alg(e))
 
#define SETCLUST(g, h)   (GD_alg(g) = h)
 
#define GETCLUST(g)   ((Agraph_t*)GD_alg(g))
 

Typedefs

using attr_map_t = std::map< std::string, AttributeValue >
 attribute name → value collection of those we have seen
 
using used_t = std::multiset< std::string >
 names that have already been used during generation
 

Functions

static void usage (int v)
 
static int setNameValue (char *arg)
 
static int setUInt (unsigned int *v, char *arg)
 
static Agsym_tagraphattr (Agraph_t *g, char *name, const char *value)
 
static Agsym_tagnodeattr (Agraph_t *g, char *name, const char *value)
 
static Agsym_tagedgeattr (Agraph_t *g, char *name, const char *value)
 
static void init (int argc, char *argv[], pack_info *pinfo)
 
static void init_node_edge (Agraph_t *g)
 
static void init_graph (Agraph_t *g, bool fill, GVC_t *gvc)
 
static void cloneDfltAttrs (Agraph_t *old, Agraph_t *new_graph, int attr_kind)
 
static void cloneAttrs (void *old, void *new_graph)
 
static void cloneEdge (Agedge_t *old, Agedge_t *new_edge)
 
static void cloneNode (Agnode_t *old, Agnode_t *new_node)
 
static void cloneCluster (Agraph_t *old, Agraph_t *new_cluster)
 
static void fillDict (attr_map_t &newdict, Agraph_t *g, int attr_kind)
 
static void fillGraph (Agraph_t *g, const attr_map_t &d, Agsym_t *(*setf)(Agraph_t *, char *, const char *), size_t cnt)
 
static void initAttrs (Agraph_t *root, std::vector< Agraph_t * > &gs)
 
static void cloneGraphAttr (Agraph_t *g, Agraph_t *ng)
 
static std::string xName (used_t &names, char *oldname)
 
static void cloneSubg (Agraph_t *g, Agraph_t *ng, Agsym_t *G_bb, used_t &gnames)
 
static void cloneClusterTree (Agraph_t *g, Agraph_t *ng)
 
static Agraph_tcloneGraph (std::vector< Agraph_t * > &gs, GVC_t *gvc, Agdesc_t kind)
 
static std::vector< Agraph_t * > readGraphs (GVC_t *gvc, std::optional< Agdesc_t > &kind)
 
static boxf compBB (std::vector< Agraph_t * > &gs)
 
int main (int argc, char *argv[])
 

Variables

gvplugin_library_t gvplugin_neato_layout_LTX_library
 
lt_symlist_t lt_preloaded_symbols []
 
static int verbose = 0
 
static char ** myFiles = 0
 
static FILE * outfp
 
static std::vector< attr_tG_args
 
static bool doPack
 
static char * gname = const_cast<char*>("root")
 
static const char useString []
 

Macro Definition Documentation

◆ GETCLUST

#define GETCLUST (   g)    ((Agraph_t*)GD_alg(g))

Definition at line 461 of file gvpack.cpp.

◆ MARK

#define MARK (   e)    (ED_alg(e) = e)

Definition at line 458 of file gvpack.cpp.

◆ MARKED

#define MARKED (   e)    (ED_alg(e))

Definition at line 459 of file gvpack.cpp.

◆ NEWNODE

#define NEWNODE (   n)    ((node_t*)ND_alg(n))

Definition at line 84 of file gvpack.cpp.

◆ SETCLUST

#define SETCLUST (   g,
 
)    (GD_alg(g) = h)

Definition at line 460 of file gvpack.cpp.

Typedef Documentation

◆ attr_map_t

using attr_map_t = std::map<std::string, AttributeValue>

Definition at line 372 of file gvpack.cpp.

◆ used_t

using used_t = std::multiset<std::string>

Definition at line 440 of file gvpack.cpp.

Function Documentation

◆ agedgeattr()

static Agsym_t * agedgeattr ( Agraph_t g,
char *  name,
const char *  value 
)
static

Definition at line 149 of file gvpack.cpp.

References agattr(), and AGEDGE.

Referenced by initAttrs().

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

◆ agnodeattr()

static Agsym_t * agnodeattr ( Agraph_t g,
char *  name,
const char *  value 
)
static

Definition at line 145 of file gvpack.cpp.

References agattr(), and AGNODE.

Here is the call graph for this function:

◆ agraphattr()

static Agsym_t * agraphattr ( Agraph_t g,
char *  name,
const char *  value 
)
static

Definition at line 141 of file gvpack.cpp.

References agattr(), and AGRAPH.

Here is the call graph for this function:

◆ cloneAttrs()

static void cloneAttrs ( void *  old,
void *  new_graph 
)
static

Definition at line 308 of file gvpack.cpp.

References aghtmlstr(), agnxtattr(), agroot(), agset(), agstrdup_html(), agstrfree(), AGTYPE, agxget(), and Agsym_s::name.

Referenced by cloneEdge(), cloneGraphAttr(), and cloneNode().

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

◆ cloneCluster()

static void cloneCluster ( Agraph_t old,
Agraph_t new_cluster 
)
static

Definition at line 357 of file gvpack.cpp.

References GD_bb, and GD_label.

Referenced by cloneClusterTree().

Here is the caller graph for this function:

◆ cloneClusterTree()

static void cloneClusterTree ( Agraph_t g,
Agraph_t ng 
)
static

Definition at line 522 of file gvpack.cpp.

References cloneCluster(), cloneClusterTree(), GD_clust, GD_n_cluster, GETCLUST, and gv_calloc().

Referenced by cloneClusterTree(), and cloneGraph().

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

◆ cloneDfltAttrs()

static void cloneDfltAttrs ( Agraph_t old,
Agraph_t new_graph,
int  attr_kind 
)
static

Definition at line 295 of file gvpack.cpp.

References agattr(), aghtmlstr(), agnxtattr(), agstrdup_html(), agstrfree(), Agsym_s::defval, and Agsym_s::name.

Referenced by cloneGraphAttr().

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

◆ cloneEdge()

static void cloneEdge ( Agedge_t old,
Agedge_t new_edge 
)
static

Definition at line 333 of file gvpack.cpp.

References cloneAttrs(), ED_edge_type, ED_head_label, ED_label, ED_spl, ED_tail_label, and ED_xlabel.

Referenced by cloneSubg().

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

◆ cloneGraph()

static Agraph_t * cloneGraph ( std::vector< Agraph_t * > &  gs,
GVC_t gvc,
Agdesc_t  kind 
)
static

Definition at line 543 of file gvpack.cpp.

References agattr(), agbindrec(), AgDefaultDisc, agfindgraphattr, agfindnode, agfstnode(), agnameof(), agnode(), agnxtnode(), agopen(), AGRAPH, agsubg(), agxset(), cloneClusterTree(), cloneNode(), cloneSubg(), doPack, G_args, GD_clust, GD_has_labels, GD_n_cluster, GETCLUST, gname, gv_calloc(), gvc, GVSPLINES, init_graph(), initAttrs(), ND_alg, State, verbose, and xName().

Referenced by main(), and mTestgvpr().

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

◆ cloneGraphAttr()

static void cloneGraphAttr ( Agraph_t g,
Agraph_t ng 
)
static

Definition at line 432 of file gvpack.cpp.

References AGEDGE, AGNODE, cloneAttrs(), and cloneDfltAttrs().

Referenced by cloneSubg().

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

◆ cloneNode()

static void cloneNode ( Agnode_t old,
Agnode_t new_node 
)
static

Definition at line 343 of file gvpack.cpp.

References cloneAttrs(), ND_coord, ND_height, ND_ht, ND_lw, ND_pos, ND_rw, ND_shape, ND_shape_info, ND_width, ND_xlabel, and POINTS.

Referenced by cloneGraph().

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

◆ cloneSubg()

static void cloneSubg ( Agraph_t g,
Agraph_t ng,
Agsym_t G_bb,
used_t gnames 
)
static

Definition at line 468 of file gvpack.cpp.

References agbindrec(), agedge(), agfstnode(), agfstout(), agfstsubg(), aghead, agnameof(), agnxtnode(), agnxtout(), agnxtsubg(), agsubg(), agsubnode(), agtail, agxset(), cloneEdge(), cloneGraphAttr(), cloneSubg(), doPack, is_a_cluster(), MARK, MARKED, NEWNODE, SETCLUST, and xName().

Referenced by cloneGraph(), and cloneSubg().

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

◆ compBB()

static boxf compBB ( std::vector< Agraph_t * > &  gs)
static

Definition at line 666 of file gvpack.cpp.

References GD_bb, boxf::LL, boxf::UR, pointf_s::x, and pointf_s::y.

Referenced by main().

Here is the caller graph for this function:

◆ fillDict()

static void fillDict ( attr_map_t newdict,
Agraph_t g,
int  attr_kind 
)
static

Definition at line 379 of file gvpack.cpp.

References agnxtattr().

Referenced by initAttrs().

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

◆ fillGraph()

static void fillGraph ( Agraph_t g,
const attr_map_t d,
Agsym_t *(*)(Agraph_t *, char *, const char *)  setf,
size_t  cnt 
)
static

Definition at line 398 of file gvpack.cpp.

References cnt().

Referenced by initAttrs().

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

◆ init()

static void init ( int  argc,
char *  argv[],
pack_info pinfo 
)
static

Definition at line 153 of file gvpack.cpp.

References agnodeattr, CL_OFFSET, pack_info::doSplines, pack_info::fixed, gname, l_clust, l_undef, pack_info::margin, pack_info::mode, myFiles, NODENAME_ESC, openFile(), outfp, parsePackModeInfo(), setNameValue(), setUInt(), pack_info::sz, usage, Verbose, and verbose.

Referenced by main().

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

◆ init_graph()

static void init_graph ( Agraph_t g,
bool  fill,
GVC_t gvc 
)
static

Definition at line 254 of file gvpack.cpp.

References AGEDGE, agfindgraphattr, agfstnode(), agfstout(), aginit(), agnameof(), AGNODE, agnxtnode(), agnxtout(), AGRAPH, Concentrate, ED_edge_type, ED_spl, GD_gvc, GD_ndim, graph_init(), graphviz_exit(), gvc, IGNORED, init_node_edge(), init_nop(), late_int(), and Ndim.

Referenced by cloneGraph(), and readGraphs().

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

◆ init_node_edge()

static void init_node_edge ( Agraph_t g)
static

Definition at line 231 of file gvpack.cpp.

References agfindnodeattr, agfstnode(), agfstout(), agnnodes(), agnxtnode(), agnxtout(), common_init_edge(), N_pos, neato_init_node(), and user_pos().

Referenced by init_graph().

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

◆ initAttrs()

static void initAttrs ( Agraph_t root,
std::vector< Agraph_t * > &  gs 
)
static

Definition at line 416 of file gvpack.cpp.

References AGEDGE, agedgeattr(), AGNODE, agnodeattr, AGRAPH, agraphattr, fillDict(), and fillGraph().

Referenced by cloneGraph().

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

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 708 of file gvpack.cpp.

References lt_symlist_t::address, agwrite(), attach_attrs(), cloneGraph(), compBB(), doPack, dotneato_postprocess(), GD_bb, graphviz_exit(), gvc, gvContextPlugins(), gvplugin_neato_layout_LTX_library, init(), l_undef, lt_preloaded_symbols, pack_info::mode, outfp, packGraphs(), and readGraphs().

Here is the call graph for this function:

◆ readGraphs()

static std::vector< Agraph_t * > readGraphs ( GVC_t gvc,
std::optional< Agdesc_t > &  kind 
)
static

Definition at line 630 of file gvpack.cpp.

References agisstrict(), agnameof(), agnnodes(), Agraph_s::desc, Agdesc_s::directed, doPack, graphviz_exit(), gvc, init_graph(), myFiles, newIngraph(), nextGraph(), Nop, POINTS_PER_INCH, PSinputscale, and verbose.

Referenced by main().

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

◆ setNameValue()

static int setNameValue ( char *  arg)
static

Definition at line 110 of file gvpack.cpp.

References G_args.

Referenced by init().

Here is the caller graph for this function:

◆ setUInt()

static int setUInt ( unsigned int *  v,
char *  arg 
)
static

Definition at line 127 of file gvpack.cpp.

Referenced by init().

Here is the caller graph for this function:

◆ usage()

static void usage ( int  v)
static

Definition at line 100 of file gvpack.cpp.

References graphviz_exit(), and useString.

Here is the call graph for this function:

◆ xName()

static std::string xName ( used_t names,
char *  oldname 
)
static

Definition at line 449 of file gvpack.cpp.

Referenced by cloneGraph(), and cloneSubg().

Here is the caller graph for this function:

Variable Documentation

◆ doPack

bool doPack
static

Definition at line 81 of file gvpack.cpp.

Referenced by cloneGraph(), cloneSubg(), main(), and readGraphs().

◆ G_args

std::vector<attr_t> G_args
static

Definition at line 80 of file gvpack.cpp.

Referenced by cloneGraph(), and setNameValue().

◆ gname

char* gname = const_cast<char*>("root")
static

Definition at line 82 of file gvpack.cpp.

Referenced by cloneGraph(), and init().

◆ gvplugin_neato_layout_LTX_library

gvplugin_library_t gvplugin_neato_layout_LTX_library
extern

Definition at line 29 of file gvplugin_neato_layout.c.

Referenced by main().

◆ lt_preloaded_symbols

lt_symlist_t lt_preloaded_symbols[]
Initial value:
= {
{ "gvplugin_neato_layout_LTX_library", &gvplugin_neato_layout_LTX_library },
{ 0, 0 }
}
gvplugin_library_t gvplugin_neato_layout_LTX_library

Definition at line 54 of file gvpack.cpp.

Referenced by main().

◆ myFiles

char** myFiles = 0
static

Definition at line 78 of file gvpack.cpp.

Referenced by init(), and readGraphs().

◆ outfp

FILE* outfp
static

Definition at line 79 of file gvpack.cpp.

Referenced by init(), and main().

◆ useString

const char useString[]
static
Initial value:
=
"Usage: gvpack [-gnuv?] [-m<margin>] {-array[_rc][n]] [-o<outf>] <files>\n\
-n - use node granularity\n\
-g - use graph granularity\n\
-array* - pack as array of graphs\n\
-G<n>=<v> - attach name/value attribute to output graph\n\
-m<n> - set margin to <n> points\n\
-s<gname> - use <gname> for name of root graph\n\
-o<outfile> - write output to <outfile>\n\
-u - no packing; just combine graphs\n\
-v - verbose\n\
-? - print usage\n\
If no files are specified, stdin is used\n"

Definition at line 86 of file gvpack.cpp.

Referenced by usage().

◆ verbose

int verbose = 0
static

Definition at line 77 of file gvpack.cpp.

Referenced by cloneGraph(), init(), and readGraphs().