GVPR(1) General Commands Manual GVPR(1) (NAME) gvpr - (SYNOPSIS) gvpr [-icnqV?] [ -o outfile ] [ -a args ] [ 'prog' | -f progfile ] [ files ] (DESCRIPTION) gvpr ( gpr ) awk . . libcgraph(3) . gvpr dot . gvpr $G - (predicate-action) . . <<>> (true) . $ . $T $O . . . (OPTIONS) : -a args args (whitespace) ARGV[0],...,ARGV[ARGC-1] gvpr . . . -a . -c . -i (node-induced subgraph extension) . -o outfile stdout . -f progfile . progfile . gvpr GVPRPATH . -f gvpr . -q . -n (read-ahead) . $NG . (block) . -v (verbose). -V . -? ..SH " (OPERANDS)" : files dot. -f . stdin . (PROGRAMS) gvpr - : BEGIN { action } BEG_G { action } N [ predicate ] { action } E [ predicate ] { action } END_G { action } END { action } BEGIN END_G END . BEG_G N E . BEG_G N E BEG_G ( ) . gvpr : BEGIN . G { { G . BEG_G . G { . N E . } } G . END_G . } END . BEGIN BEG_G END_G END . N E . . (true) . . N ( E) . N E . C expr(3) . . C (non-zero) . . . C (void int char float long unsigned double) gvpr string char* node_t edge_t graph_t obj_t . obj_t . () . C "..." '...' . gvpr ++C cpp . '#' . . (scope) . : type array [ type0 ] type0 . (parser) . . C . . : { [ statement ... ] } expression // var = expression if( expression ) statement [ else statement ] for( expression ; expression ; expression ) statement for( array [ var ]) statement forr( array [ var ]) statement while( expression ) statement switch( expression ) case statements break [ expression ] continue [ expression ] return [ expression ] . for forr var () statement . for ( forr) () . . BEGIN . C . == != . ksh(1) . ( strcmp ). gvpr . C . ( graph_t node_t edge_t obj_t) .name . name . . N E BEG_G END_G . libcgraph(3) . gvpr . . head : node_t ..TP tail : node_t . name : string . "[]" "->" "--" . [] () . indegree : int . outdegree : int . degree : int . X : double X . ( pos .) Y : double Y . ( pos .) root : graph_t . . parent : graph_t . NULL . n_edges : int . n_nodes : int . directed : int () . strict : int (strict) () . (BUILT-IN FUNCTIONS) gvpr . NULL . (Graphs and subgraph) graph(s : string, t : string) : graph_t s t . U, D, S, N (undirected) (directed) (strict) (non-strict) . t . subg(g : graph_t, s : string) : graph_t s g . . isSubg(g : graph_t, s : string) : graph_t s g NULL . fstsubg(g : graph_t) : graph_t g NULL . nxtsubg(sg : graph_t) : graph_t sg NULL . isDirect(g : graph_t) : int g (true) . isStrict(g : graph_t) : int g (true) . nNodes(g : graph_t) : int g . nEdges(g : graph_t) : int g ..SS " (Nodes)" node(g : graph_t, s : string) : node_t s g . . subnode(sg : graph_t, n : node_t) : node_t n sg . . fstnode(g : graph_t) : node_t g NULL . nxtnode(n : node_t) : node_t n NULL . nxtnode_sg(sg : graph_t, n : node_t) : node_t n sg NULL . isNode(sg : graph_t, s : string) : node_t () sg s . NULL . isSubnode(sg : graph_t, n : node_t) : int n () sg . indegreeOf(sg : graph_t, n : node_t) : int n () sg . outdegreeOf(sg : graph_t, n : node_t) : int n () sg . degreeOf(sg : graph_t, n : node_t) : int n () sg . rename(n : node_t, newname : string) : int n newname 0 -1 . (Edges) edge(t : node_t, h : node_t, s : string) : edge_t t h s . . . edge_sg(sg : graph_t, t : node_t, h : node_t, s : string) : edge_t t h s () sg ( ) . . . subedge(g : graph_t, e : edge_t) : edge_t e g . . isEdge(t : node_t, h : node_t, s : string) : edge_t t h s . . NULL . isEdge_sg(sg : graph_t, t : node_t, h : node_t, s : string) : edge_t () sg t h s . . NULL . isSubedge(sg : graph_t, e : edge_t) : int e () sg . fstout(n : node_t) : edge_t n . fstout_sg(sg : graph_t, n : node_t) : edge_t n () sg . nxtout(e : edge_t) : edge_t e . nxtout_sg(sg : graph_t, e : edge_t) : edge_t e sg . fstin(n : node_t) : edge_t n . fstin_sg(sg : graph_t, n : node_t) : edge_t n sg . nxtin(e : edge_t) : edge_t e . nxtin_sg(sg : graph_t, e : edge_t) : edge_t e sg . fstedge(n : node_t) : edge_t n . fstedge_sg(sg : graph_t, n : node_t) : edge_t n sg . nxtedge(e : edge_t, n : node_t) : edge_t e . nxtedge_sg(sg : graph_t, e : edge_t, n : node_t) : edge_t e sg . opp(e : edge_t, n : node_t) : node_t e n . n e NULL . fstedge nxtedge n ..SS "/ (Graph I/O)" write(g : graph_t) : void g dot . writeG(g : graph_t, fname : string) : void g dot fname . fwriteG(g : graph_t, fd : int) : void g dot fd . readG(fname : string) : graph_t fname . dot . NULL . freadG(fd : int) : graph_t fd . NULL . (Graph miscellany) delete(g : graph_t, x : obj_t) : void x g . g NULL x . x x . isIn(g : graph_t, x : obj_t) : int x g (true) . cloneG(g : graph_t, s : string) : graph_t ( ) g s . s "" g . clone(g : graph_t, x : obj_t) : obj_t x g . / . x x . . . x g NULL . cloneG(x,"") . copy(g : graph_t, x : obj_t) : obj_t x g / . x x . (shallow copy) . x . x . x g NULL . copyA(src : obj_t, tgt : obj_t) : int src tgt tgt . induce(g : graph_t) : void g (node-induced) . hasAttr(src : obj_t, name : string) : int src name 0 . isAttr(g : graph_t, kind : string, name : string) : int name g kind . kind "N" "E" "G" . 0 . aget(src : obj_t, name : string) : string name src . name "head" "root" . "" . hasAttr isAttr . aset(src : obj_t, name : string, value : string) : int name src value . 0 (non-zero) . aget . getDflt(g : graph_t, kind : string, name : string) : string name kind g . kind "N" "E" "G" . "" . isAttr . setDflt(g : graph_t, kind : string, name : string, value : string) : int name kind g value . kind "N" "E" "G" . 0 . getDflt . fstAttr(g : graph_t, kind : string) : string g kind . kind "N" "E" "G" . "" . nxtAttr(g : graph_t, kind : string, name : string) : string g kind name . name fstAttr nxtAttr . kind "N" "E" "G" . "" . compOf(g : graph_t, n : node_t) : graph_t g n g . . induce . n g NULL . g . kindOf(obj : obj_t) : string obj . "N" "E" "G" . lock(g : graph_t, v : int) : int . v delete . v . . v . ..SS " (Strings)" sprintf(fmt : string, ...) : string fmt printf(3) fmt . gsub(str : string, pat : string) : string gsub(str : string, pat : string, repl : string) : string str pat repl . sub(str : string, pat : string) : string sub(str : string, pat : string, repl : string) : string str pat repl . '^' '$' pat str . substr(str : string, idx : int) : string substr(str : string, idx : int, len : int) : string str idx len . 0 . idx idx str . len idx + len str . strcmp(s1 : string, s2 : string) : int C strcmp(3) . length(s : string) : int s . index(s : string, t : string) : int rindex(s : string, t : string) : int s () t t s -1 . match(s : string, p : string) : int s p s p -1 . toupper(s : string) : string s . tolower(s : string) : string s . canon(s : string) : string s dot . html(g : graph_t, s : string) : string "" s HTML . HTML . g . g HTML g . (angle bracket quotes) s . g DOT . ishtml(s : string) : int s HTML . xOf(s : string) : string s "x,y" x y "x" . yOf(s : string) : string s "x,y" x y "y" . llOf(s : string) : string s "llx,lly,urx,ury" llx lly urx ury "llx,lly" . urOf(s) urOf(s : string) : string s "llx,lly,urx,ury" llx lly urx ury "urx,ury" . sscanf(s : string, fmt : string, ...) : int s sscanf(3) fmt . fmt &v v . . split(s : string, arr : array, seps : string) : int split(s : string, arr : array) : int tokens(s : string, arr : array, seps : string) : int tokens(s : string, arr : array) : int split s tokens (tokens) . . . (token) . seps . seps " \t\n" . . . string int . 0 . ..SS "/ (I/O)" print(...) : void print( expr, ... ) stdout . printf(fmt : string, ...) : int printf(fd : int, fmt : string, ...) : int fmt fmt printf(3) . 0 . stdout . fd fd . scanf(fmt : string, ...) : int scanf(fd : int, fmt : string, ...) : int fmt scanf(3) . fmt &v v . stdin . fd fd . . openF(s : string, t : string) : int s I/O . t . C fopen(3) . -1 . 0 1 2 stdin stdout stderr . gvpr stdin . closeF(fd : int) : int fd . 0 1 2 . 0 . readL(fd : int) : string fd . "" . . (Math) exp(d : double) : double e d . log(d : double) : double d . sqrt(d : double) : double d . pow(d : double, x : double) : double d x . cos(d : double) : double d . sin(d : double) : double d . atan2(y : double, x : double) : double y/x -pi pi . MIN(y : double, x : double) : double y x . MAX(y : double, x : double) : double y x ..SS " (Associative Arrays)" # arr : int arr . idx in arr : int idx arr 1 . 0 . unset(v : array, idx) : int idx . 1 0 . unset(v : array) : void . (Miscellaneous) exit(v : int) : void gvpr v . system(cmd : string) : int system(3) . cmd . rand() : double double - 0 1 . srand() : int srand(v : int) : int (seed) . . . srand rand . colorx(color : string, fmt : string) : string . color . fmt "RGB" "RGBA" "HSV" "HSVA" . . (BUILT-IN VARIABLES) gvpr (context) gvpr . . $ : obj_t ( ) . BEGIN END . $F : string . $G : graph_t . BEGIN END . $NG : graph_t . $NG NULL $G . stdin (pipe) . BEGIN END -n . $O : graph_t . . END_G - . N E END_G . . $T : graph_t . $G N E END_G . $tgtname : string . "gvpr_result" . gvpr . . $tvroot : node_t ( ) ( $tvtype ). NULL . $tvroot $tvroot . $tvnext . $tvnext : node_t ( ) ( $tvtype ). $tvroot $tvnext $tvroot . NULL . $tvedge : edge_t BFS DFS . NULL . $tvtype : tvtype_t gvpr . "TV_" . TV_flat . cgraph(3) . TV_fwd . ARGC : int -a args . ARGV : string array -a args . i- ARGV[i] ..SH " (BUILT-IN CONSTANTS)" gvpr . NULL : obj_t 0. TV_flat : tvtype_t . TV_ne : tvtype_t . TV_en : tvtype_t . TV_dfs : tvtype_t TV_postdfs : tvtype_t TV_prepostdfs : tvtype_t . gvpr $tvroot . ( NULL ) gvpr . $tvroot $tvroot NULL . TV_dfs $tvroot . (pre-order) . TV_postdfs . TV_prepostdfs : . TV_fwd : tvtype_t TV_postfwd : tvtype_t TV_prepostfwd : tvtype_t . TV_dfs . TV_fwd TV_postfwd TV_prepostfwd TV_dfs TV_postdfs TV_prepostdfs . TV_rev : tvtype_t TV_postrev : tvtype_t TV_prepostrev : tvtype_t . TV_dfs . TV_rev TV_postrev TV_prepostrev TV_dfs TV_postdfs TV_prepostdfs . TV_bfs : tvtype_t . $tvroot TV_dfs . (EXAMPLES) gvpr -i 'N[color=="blue"]' file.gv (node-induced) . gvpr -c 'N[color=="blue"]{color = "red"}' file.gv . BEGIN { int n, e; int tot_n = 0; int tot_e = 0; } BEG_G { n = nNodes($G); e = nEdges($G); printf ("%d nodes %d edges %s\n", n, e, $G.name); tot_n += n; tot_e += e; } END { printf ("%d nodes %d edges total\n", tot_n, tot_e) } gc. BEG_G { graph_t g = graph ("merge", "S"); } E { node_t h = clone(g,$.head); node_t t = clone(g,$.tail); edge_t e = edge(t,h,""); e.weight = e.weight + 1; } END_G { $O = g; } (strict) weight . BEGIN {node_t n; int deg[]} E{deg[head]++; deg[tail]++; } END_G { for (deg[n]) { printf ("deg[%s] = %d\n", n.name, deg[n]); } } . BEGIN { int i, indent; int seen[string]; void prInd (int cnt) { for (i = 0; i < cnt; i++) printf (" "); } } BEG_G { $tvtype = TV_prepostfwd; $tvroot = node($,ARGV[0]); } N { if (seen[$.name]) indent--; else { prInd(indent); print ($.name); seen[$.name] = 1; indent++; } } ARGV[0] ..SH " (ENVIRONMENT)" GVPRPATH (":") -f . gvpr . GVPRPATH . GVPRPATH GVPRPATH . GVPRPATH GVPRPATH . GVPRPATH . Windows "semicolon" () "colon" () . (BUGS AND WARNINGS) N{} E{} BFS DFS . gvpr . (single quotes) . (escape) . strcmp . gvpr . nxtnode . <<_sg>> . (root graph) . (global scope) . (extent) . . . IF return (type checking) . return . expr (char*)0 . "" (char*)0 . "" (char*)0 . (integer) char . ((int)"2") . C (dangling references) '=' '==' . (AUTHORS) Emden R. Gansner (SEE ALSO) awk(1), gc(1), dot(1), nop(1), expr(3), cgraph(3) 29 August 2013 GVPR(1)