gvpr

graph stream editor, similar to awk for graphs

TLDR

Run gvpr script
$ gvpr -f [script.gvpr] [input.gv]
Inline program
$ gvpr 'N[color=="red"]' [input.gv]
Output to file
$ gvpr -o [output.gv] -f [script.gvpr] [input.gv]
Select nodes by attribute
$ gvpr 'N[degree>3]' [graph.gv]

SYNOPSIS

gvpr [-icnqV?] [-o outfile] [-a args] 'prog' | -f progfile [files]

DESCRIPTION

gvpr (formerly gpr) is a graph pattern scanning and processing language, similar to awk but for graphs instead of text. Programs consist of pattern-action clauses (BEGIN, BEG_G, N for nodes, E for edges, END_G, END) that are matched against each input graph in turn.For each node or edge visited, gvpr evaluates the predicates in order and runs the associated action for the first (or every) match. The language provides C-like types, associative arrays, and built-in graph functions, letting programs filter, transform, restructure, or compute statistics over DOT graphs.

PARAMETERS

'prog'

Inline gvpr program text (a series of predicate-action clauses). Required unless -f is given.
FILES
Input graph files in DOT format. Reads stdin if none given.
-f progfile
Read the gvpr program from progfile instead of the command line.
-o outfile
Write output to outfile instead of stdout.
-a args
Pass a whitespace-separated argument string to the program, available as ARGV/ARGC.
-c
Use the source graph as the output graph, so in-place edits are emitted.
-i
Derive the output as the node-induced subgraph extension in the context of its root graph.
-n
Disable graph read-ahead (affects the $NG variable).
-q
Suppress warning messages.
-V
Print version information and exit.
-?
Display usage information and exit.

INSTALL

sudo apt install graphviz
sudo dnf install graphviz
sudo pacman -S graphviz
sudo apk add graphviz
sudo zypper install graphviz
brew install graphviz
nix profile install nixpkgs#graphviz

CAVEATS

Part of the Graphviz package. The pattern-action language has a learning curve, and complex programs over large graphs can be slow.

HISTORY

gvpr was developed as part of Graphviz at AT&T Labs to provide AWK-like processing for graph structures, replacing the earlier gpr tool.

SEE ALSO

dot(1), awk(1), gc(1), nop(1)

RESOURCES

Homepage · Source code · Documentation