gvpr
Process graph data
SYNOPSIS
gvpr [-c] [-i] [-n] [-q] [-V] [-dname=value]... [-f progfile] [program [infile...]]
PARAMETERS
-c
Treat program argument as executable code (default reads as filename)
-i
Ignore format errors in input graphs
-n
Do not print input graphs; only emit modified ones
-q
Quiet mode: suppress informational messages
-V
Print version information and exit
-dname=value
Define global variable before program execution
-f progfile
Read program code from specified file instead of argument
DESCRIPTION
gvpr is a stream editor for graphs, inspired by awk and sed, designed for processing Graphviz graphs in DOT language format.
It reads graphs from standard input or files, applies user-defined programs written in the gvpr scripting language, and outputs modified graphs to standard output. The language provides access to graph, subgraph, node, and edge attributes, allowing complex manipulations like filtering nodes, transforming edges, computing statistics, or generating reports.
Common uses include graph filtering, layout adjustments, attribute modifications, and data extraction from visualization pipelines. gvpr supports variables, functions, loops, conditionals, and Graphviz-specific primitives (e.g., N for nodes, E for edges). It's powerful for batch processing large graph datasets in automation scripts or data analysis workflows.
Programs can be inline, from files, or stdin, making it flexible for one-liners or complex scripts.
CAVEATS
Requires Graphviz installation; gvpr language has a learning curve similar to awk. Input must be valid DOT; large graphs may consume significant memory. No built-in graph rendering—pair with dot(1) for visualization.
GVPR LANGUAGE BASICS
Uses four main input loops: B (begin), N (nodes), E (edges), T (terminate). Example: B { stdin; } N { if ($color == "red") delete($g,$n); } E { stdout; }
SIMPLE EXAMPLE
Filter red nodes: gvpr -c 'N{ if($color=="red") delete($g,$); }' input.dot
HISTORY
Developed as part of Graphviz by AT&T Bell Labs researchers (John Ellson et al.) around 2004. Evolved with Graphviz releases; stable in versions 2.0+. Widely used in graph analysis tools and academic workflows.


