LinuxCommandLibrary

gvpack

Pack Graphviz graphs into single file

TLDR

Combine several graph layouts (that already have layout information)

$ gvpack [path/to/layout1.gv path/to/layout2.gv ...] > [path/to/output.gv]
copy

Combine several graph layouts at the graph level, keeping graphs separate
$ gvpack -g [path/to/layout1.gv path/to/layout2.gv ...] > [path/to/output.gv]
copy

Combine several graph layouts at the node level, ignoring clusters
$ gvpack -n [path/to/layout1.gv path/to/layout2.gv ...] > [path/to/output.gv]
copy

Combine several graph layouts without packing
$ gvpack -u [path/to/layout1.gv path/to/layout2.gv ...] > [path/to/output.gv]
copy

Display help
$ gvpack -?
copy

SYNOPSIS

gvpack [ options ] [ files ]

files: One or more Graphviz DOT language files containing graphs to be packed. If no files are specified, gvpack reads from standard input.

PARAMETERS

-A
    Use node adjacency to determine how graphs are clustered and packed. Useful for breaking large graphs into smaller components.

-C
    Place each connected component of a graph on its own separate page.

-g
    Pad each packed graph with an empty margin, typically a default of 8 points.

-Gattr
    Set a default graph attribute. For example, -G'pad=0.5' can modify the padding of graphs.

-Lflags
    Set the level of packing. flags can be combinations of 'x' (pack by x-coordinate), 'y' (pack by y-coordinate), 'c' (connected components), 'm' (master graphs), 'a' (array-based packing).

-mmargin
    Set the page margin for the output. This value specifies the space around the packed graphs.

-ooutput_file
    Write the packed graph to the specified output_file. If omitted, output goes to standard output.

-P
    Pack all graphs onto a single page. This is the default behavior if no other page-related flags are specified.

-u
    Unpack graphs. This reverses the packing operation, potentially expanding previously packed graphs.

-v
    Enable verbose output, providing information about the packing process.

-x
    Place each graph from the input files on its own separate page.

DESCRIPTION

gvpack is a utility from the Graphviz suite designed to arrange multiple independent graphs onto a smaller combined space, typically a single page, by minimizing the empty space between them. It takes one or more Graphviz DOT language files as input, which may contain single or multiple graphs.

gvpack applies algorithms to reposition these graphs such that they are tightly packed without overlapping, while preserving their internal layouts. This is particularly useful when visualizing many small graphs, such as components of a larger system, on a single output document. The command can output the packed graph in various formats, including DOT, allowing further processing by other Graphviz layout engines like dot or neato for final rendering. It significantly aids in creating more compact and readable composite visualizations.

CAVEATS

gvpack aims for efficiency but does not guarantee the absolute optimal packing arrangement in all cases, especially for complex graph collections.

Extremely large graphs or a very high number of graphs might still result in layouts that require manual adjustments or alternative strategies.

While gvpack minimizes overlap between distinct graphs, internal node/edge overlaps within a single graph are handled by the layout engine (e.g., dot, neato) that processes the output of gvpack.

TYPICAL WORKFLOW

gvpack is often used as a preprocessing step in a Graphviz pipeline. A common workflow involves piping the output of gvpack to another Graphviz layout engine for final rendering.
Example: cat graphs/*.dot | gvpack -P | dot -Tpng -o combined_graphs.png

INPUT AND OUTPUT

The primary input format for gvpack is the Graphviz DOT language. The output is also in DOT format by default, making it interoperable with other Graphviz tools. This allows for flexible pipelines where packing is just one step in a larger visualization process.

HISTORY

gvpack is an integral part of the open-source Graphviz graph visualization software suite, which originated at AT&T Labs Research. Developed to address the challenge of efficiently visualizing multiple graphs, it became a crucial utility for generating composite layouts. Its evolution parallels the broader development of Graphviz, continuously improving algorithms for better graph packing and layout optimization, adapting to diverse visualization needs for complex data structures and networks.

SEE ALSO

dot(1), neato(1), fdp(1), sfdp(1), twopi(1), circo(1), gvpr(1), gvmap(1)

Copied to clipboard