gvgen
Generate graphs from grammar
TLDR
Generate a [c]ycle with 10 vertices and edges and write it to stdout
Generate a 4×3 [g]rid
Generate a binary [t]ree of height 5
Generate a complete [b]ipartite graph with 3 and 4 vertices
Create a [r]andom graph and [o]utput it to a file
Generate a [d]irected graph with [v]erbose output
Display help
SYNOPSIS
gvgen [-Dminlen] [-dmaxlen] [-N] [-Rmaxnodes] [-rseed] [-u]
PARAMETERS
-Dminlen
minimum label length (default 1)
-dmaxlen
maximum label length (default 10)
-N
numbered nodes instead of random labels
-Rmaxnodes
maximum nodes (default 20)
-rseed
random seed for reproducibility
-u
undirected graph (default directed)
DESCRIPTION
gvgen is a compact C utility for generating random directed graphs in GraphViz's DOT format, suitable for piping to tools like dot(1) or neato(1) to create visualizations. It produces a digraph with up to 20 nodes by default, randomly connecting them with directed edges. Node labels are random alphanumeric strings (a-z, 0-9), with lengths between 1 and 10 characters.
Key customizations include setting minimum/maximum label lengths, capping the node count, using sequential numbers (1, 2, ...) for labels, providing a random seed for reproducible output, or making the graph undirected. No input files are required; it runs deterministically with a seed or randomly otherwise.
Primarily used for testing GraphViz setups, creating sample graphs for demos/tutorials, or prototyping layouts. Output is plain text DOT, easily viewable or convertible to PNG/SVG/PS.
Example:
gvgen -u -R 25 -r 42 | dot -Tpng -o random_graph.png
This creates a reproducible undirected graph with ≤25 nodes and renders it as PNG.
CAVEATS
Graphs are random with no control over topology/connectivity; for testing only. Not in standard distros; download/compile from acme.com/software/gvgen/. Labels exclude special chars.
QUICK USAGE
gvgen | dot -Tsvg > graph.svg
Pipe to GraphViz for instant visualization.
gvgen -N -u -R50 -r123 | fdp -Tpdf > undirected.pdf
Numbered undirected graph with 50 nodes.
SAMPLE DOT OUTPUT
digraph G {
a1 -> b7;
b7 -> c2;
...
}
HISTORY
Created by Jef Poskanzer circa 2001 as part of acme.com software tools. Simple C program; unchanged since initial release, focused on reliability for GraphViz testing.


