gv(3sharp)
okay so this is gv(3sharp) and itβs literally the graph-manipulation manual, bestie π
β¨ buckle up because weβre about to make graphviz make sense.
πΈ NAME πΈ
gv_sharp β graph manipulation in sharp π¦
β SYNOPSIS β
no synopsis lines here, bestie β it jumps straight into USAGE and INTRODUCTION β¨
π§ USAGE π§
the original has no usage text here, just vibes π
π INTRODUCTION π
gv_sharp is a dynamically loaded extension for sharp that gives you access to the graph facilities of graphviz. no cap, thatβs the whole intro and it ate π«Ά
π¦ COMMANDS π¦
okay so this is the whole command menu. every signature is kept exactly as the original has it β no renames, no βfixing,β no funny business π₯
β¨ New graphs β¨
New empty graph
SWIGTYPE_p_Agraph_t gv.graph (string name);
SWIGTYPE_p_Agraph_t gv.digraph (string name);
SWIGTYPE_p_Agraph_t gv.strictgraph (string name);
SWIGTYPE_p_Agraph_t gv.strictdigraph (string name);
four ways to start a fresh empty graph, each one taking a name and handing you back a graph handle π
New graph from a dot-syntax string or file
SWIGTYPE_p_Agraph_t gv.readstring (string string);
SWIGTYPE_p_Agraph_t gv.read (string filename);
SWIGTYPE_p_Agraph_t gv.read (SWIGTYPE_p_FILE f);
readstring takes a dot-syntax string, and read takes either a filename or an open FILE handle. super straightforward, iconic behavior π
Add new subgraph to existing graph
SWIGTYPE_p_Agraph_t gv.graph (SWIGTYPE_p_Agraph_t g, string name);
drops a new subgraph into an existing graph g, with the name you pass in π
π New nodes π
Add new node to existing graph
SWIGTYPE_p_Agnode_t gv.node (SWIGTYPE_p_Agraph_t g, string name);
adds a new node to graph g and gives you the node handle back π«
π« New edges π«
Add new edge between existing nodes
SWIGTYPE_p_Agedge_t gv.edge (SWIGTYPE_p_Agnode_t t, SWIGTYPE_p_Agnode_t h);
connects existing tail node t to existing head node h, and you get the edge handle π«Ά
Add a new edge between an existing tail node, and a named head node which will be induced in the graph if it doesnβt already exist
SWIGTYPE_p_Agedge_t gv.edge (SWIGTYPE_p_Agnode_t t, string hname);
tail node is already there, and the named head node gets induced into the graph if itβs not already a thing β¨
Add a new edge between an existing head node, and a named tail node which will be induced in the graph if it doesnβt already exist
SWIGTYPE_p_Agedge_t gv.edge (string tname, SWIGTYPE_p_Agnode_t h);
same energy, but flipped: named tail gets induced if needed, and the head node already exists π
Add a new edge between named tail and head nodes which will be induced in the graph if they donβt already exist
SWIGTYPE_p_Agedge_t gv.edge (SWIGTYPE_p_Agraph_t g, string tname, string hname);
named tail and named head both get induced into graph g if they arenβt already there. main character edge energy for real π
π Setting attribute values π
Set value of named attribute of graph/node/edge β creating attribute if necessary
string gv.setv (SWIGTYPE_p_Agraph_t g, string attr, string val);
string gv.setv (SWIGTYPE_p_Agnode_t n, string attr, string val);
string gv.setv (SWIGTYPE_p_Agedge_t e, string attr, string val);
sets the value of a named attribute on a graph, node, or edge, and creates the attribute if it has to. returns a string π
Set value of existing attribute of graph/node/edge (using attribute handle)
string gv.setv (SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agsym_t a, string val);
string gv.setv (SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agsym_t a, string val);
string gv.setv (SWIGTYPE_p_Agedge_t e, SWIGTYPE_p_Agsym_t a, string val);
same setv era, but youβre passing an attribute handle a instead of a name. still returns a string π
π Getting attribute values π
Get value of named attribute of graph/node/edge
string gv.getv (SWIGTYPE_p_Agraph_t g, string attr);
string gv.getv (SWIGTYPE_p_Agnode_t n, string attr);
string gv.getv (SWIGTYPE_p_Agedge_t e, string attr);
grabs the value of a named attribute from a graph, node, or edge, and hands it back as a string β¨
Get value of attribute of graph/node/edge (using attribute handle)
string gv.getv (SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agsym_t a);
string gv.getv (SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agsym_t a);
string gv.getv (SWIGTYPE_p_Agedge_t e, SWIGTYPE_p_Agsym_t a);
same getv energy but with an attribute handle a instead of a name. returns a string π
π«Ά Obtain names from handles π«Ά
string gv.nameof (SWIGTYPE_p_Agraph_t g);
string gv.nameof (SWIGTYPE_p_Agnode_t n);
string gv.nameof (SWIGTYPE_p_Agsym_t a);
youβve got a handle, you want the name β gv.nameof says βsay lessβ and returns a string π
π Find handles from names π
SWIGTYPE_p_Agraph_t gv.findsubg (SWIGTYPE_p_Agraph_t g, string name);
SWIGTYPE_p_Agnode_t gv.findnode (SWIGTYPE_p_Agraph_t g, string name);
SWIGTYPE_p_Agedge_t gv.findedge (SWIGTYPE_p_Agnode_t t, SWIGTYPE_p_Agnode_t h);
SWIGTYPE_p_Agsym_t gv.findattr (SWIGTYPE_p_Agraph_t g, string name);
SWIGTYPE_p_Agsym_t gv.findattr (SWIGTYPE_p_Agnode_t n, string name);
SWIGTYPE_p_Agsym_t gv.findattr (SWIGTYPE_p_Agedge_t e, string name);
the βI know the name, now give me the handleβ corner. subgraphs, nodes, edges, and attributes all get their finder moment π₯
π§ Misc graph navigators returning handles π§
SWIGTYPE_p_Agnode_t gv.headof (SWIGTYPE_p_Agedge_t e);
SWIGTYPE_p_Agnode_t gv.tailof (SWIGTYPE_p_Agedge_t e);
SWIGTYPE_p_Agraph_t gv.graphof (SWIGTYPE_p_Agraph_t g);
SWIGTYPE_p_Agraph_t gv.graphof (SWIGTYPE_p_Agedge_t e);
SWIGTYPE_p_Agraph_t gv.graphof (SWIGTYPE_p_Agnode_t n);
SWIGTYPE_p_Agraph_t gv.rootof (SWIGTYPE_p_Agraph_t g);
little navigator besties that hand you back handles: head, tail, graph-of-this, graph-of-that, and root. iykyk π
π§ Obtain handles of proto node/edge for setting default attribute values π§
SWIGTYPE_p_Agnode_t gv.protonode (SWIGTYPE_p_Agraph_t g);
SWIGTYPE_p_Agedge_t gv.protoedge (SWIGTYPE_p_Agraph_t g);
grab the proto node or proto edge handle for graph g when youβre setting default attribute values. very βset the vibe for everyoneβ of them π
π Iterators π
Iteration termination tests
bool gv.ok (SWIGTYPE_p_Agraph_t g);
bool gv.ok (SWIGTYPE_p_Agnode_t n);
bool gv.ok (SWIGTYPE_p_Agedge_t e);
bool gv.ok (SWIGTYPE_p_Agsym_t a);
the bool check that tells you whether your iteration handle is still okay. graph, node, edge, attribute β all covered β
Iterate over subgraphs of a graph
SWIGTYPE_p_Agraph_t gv.firstsubg (SWIGTYPE_p_Agraph_t g);
SWIGTYPE_p_Agraph_t gv.nextsubg (SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agraph_t sg);
first subgraph, then keep calling nextsubg with the current subgraph handle. classic iteration slay π¦
Iterate over supergraphs of a graph (obscure and rarely useful)
SWIGTYPE_p_Agraph_t gv.firstsupg (SWIGTYPE_p_Agraph_t g);
SWIGTYPE_p_Agraph_t gv.nextsupg (SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agraph_t sg);
yes bestie, the original literally calls this obscure and rarely useful β so proceed with lowkey caution π
Iterate over edges of a graph
SWIGTYPE_p_Agedge_t gv.firstedge (SWIGTYPE_p_Agraph_t g);
SWIGTYPE_p_Agedge_t gv.nextedge (SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agedge_t e);
walks the edges of graph g, first one then next one until youβre done π₯
Iterate over outedges of a graph
SWIGTYPE_p_Agedge_t gv.firstout (SWIGTYPE_p_Agraph_t g);
SWIGTYPE_p_Agedge_t gv.nextout (SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agedge_t e);
same idea but for outedges of a graph. outedge era π«
Iterate over edges of a node
SWIGTYPE_p_Agedge_t gv.firstedge (SWIGTYPE_p_Agnode_t n);
SWIGTYPE_p_Agedge_t gv.nextedge (SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agedge_t e);
edge iteration, but scoped to node n π
Iterate over out-edges of a node
SWIGTYPE_p_Agedge_t gv.firstout (SWIGTYPE_p_Agnode_t n);
SWIGTYPE_p_Agedge_t gv.nextout (SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agedge_t e);
out-edge iteration for a single node. no cap, itβs giving βfollow the outgoing connectionsβ π
Iterate over head nodes reachable from out-edges of a node
SWIGTYPE_p_Agnode_t gv.firsthead (SWIGTYPE_p_Agnode_t n);
SWIGTYPE_p_Agnode_t gv.nexthead (SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agnode_t h);
walks the head nodes you can reach from node nβs out-edges. head node hunting, but make it cute π«Ά
Iterate over in-edges of a graph
SWIGTYPE_p_Agedge_t gv.firstin (SWIGTYPE_p_Agraph_t g);
SWIGTYPE_p_Agedge_t gv.nextin (SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agedge_t e);
in-edge iteration for a graph. yes, the second signature is written exactly like that in the original β copy it as-is, bestie π
Iterate over in-edges of a node
SWIGTYPE_p_Agedge_t gv.firstin (SWIGTYPE_p_Agnode_t n);
SWIGTYPE_p_Agedge_t gv.nextin (SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agedge_t e);
in-edge iteration for a node. again, the second line is exactly the original signature β no edits from me π
Iterate over tail nodes reachable from in-edges of a node
SWIGTYPE_p_Agnode_t gv.firsttail (SWIGTYPE_p_Agnode_t n);
SWIGTYPE_p_Agnode_t gv.nexttail (SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agnode_t t);
tail node iteration from node nβs in-edges. tail besties, assemble πΈ
Iterate over nodes of a graph
SWIGTYPE_p_Agnode_t gv.firstnode (SWIGTYPE_p_Agraph_t g);
SWIGTYPE_p_Agnode_t gv.nextnode (SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agnode_t n);
walks every node in graph g. first node, next node, periodt π
Iterate over nodes of an edge
SWIGTYPE_p_Agnode_t gv.firstnode (SWIGTYPE_p_Agedge_t e);
SWIGTYPE_p_Agnode_t gv.nextnode (SWIGTYPE_p_Agedge_t e, SWIGTYPE_p_Agnode_t n);
node iteration scoped to edge e. yes, edges have nodes, and theyβre getting iterated π
Iterate over attributes of a graph
SWIGTYPE_p_Agsym_t gv.firstattr (SWIGTYPE_p_Agraph_t g);
SWIGTYPE_p_Agsym_t gv.nextattr (SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agsym_t a);
walks the attributes attached to graph g. attribute handle by attribute handle β¨
Iterate over attributes of an edge
SWIGTYPE_p_Agsym_t gv.firstattr (SWIGTYPE_p_Agedge_t e);
SWIGTYPE_p_Agsym_t gv.nextattr (SWIGTYPE_p_Agedge_t e, SWIGTYPE_p_Agsym_t a);
edge attribute iteration. every edge deserves its attribute moment π
Iterate over attributes of a node
SWIGTYPE_p_Agsym_t gv.firstattr (SWIGTYPE_p_Agnode_t n);
SWIGTYPE_p_Agsym_t gv.nextattr (SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agsym_t a);
node attribute iteration, same energy. iconic π¦
π Remove graph objects π
bool gv.rm (SWIGTYPE_p_Agraph_t g);
bool gv.rm (SWIGTYPE_p_Agnode_t n);
bool gv.rm (SWIGTYPE_p_Agedge_t e);
removes a graph, node, or edge, and returns a bool. the βrespectfully, delete itβ corner π
π Layout π
Annotate a graph with layout attributes and values using a specific layout engine
bool gv.layout (SWIGTYPE_p_Agraph_t g, string engine);
runs layout on graph g with the engine you name, annotating it with layout attributes and values. returns a bool π
π¨ Render π¨
Render a layout into attributes of the graph
bool gv.render (SWIGTYPE_p_Agraph_t g);
renders a layout into the graphβs own attributes and returns a bool π«Ά
Render a layout to stdout
bool gv.render (SWIGTYPE_p_Agraph_t g, string format);
renders to stdout in the format you pass. yes bestie, straight to stdout π«
Render to an open file
bool gv.render (SWIGTYPE_p_Agraph_t g, string format, SWIGTYPE_p_FILE fout);
renders into the already-open file handle fout π
Render a layout to an unopened file by name
bool gv.render (SWIGTYPE_p_Agraph_t g, string format, string filename);
gives you the filename version β it renders to a file by filename instead of an open handle π
Render to a string result
string gv.renderresult (SWIGTYPE_p_Agraph_t ing, string format);
gv.renderresult (SWIGTYPE_p_Agraph_t g, string format, string outdata);
the first one returns a string; the second is written exactly like that in the original β no return type, donβt @ me π keep it exact, bestie.
Render to an open channel
bool gv.renderchannel (SWIGTYPE_p_Agraph_t g, string format, string channelname);
renders to the open channel named by channelname, and returns a bool π₯
Render a layout to a mallocβed string, to be freeβd by the caller
deprecated β too easy to leak memory π
still needed for "eval [gv::renderdata $G tk]" β yes, that exact quote is in the original.
string gv.renderdata (SWIGTYPE_p_Agraph_t g, string format);
returns a string thatβs been mallocβed and has to be freeβd by the caller. deprecated because memory leaks are not the vibe, but still needed for that exact "eval [gv::renderdata $G tk]" situation π
πΎ Writing graph back to file πΎ
bool gv.write (SWIGTYPE_p_Agraph_t g, string filename);
bool gv.write (SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_FILE f);
writes graph g back out β either by filename or to an open FILE handle f. returns a bool π
π§ Graph transformation tools π§
bool gv.tred (SWIGTYPE_p_Agraph_t g);
the transformation-tools corner: gv.tred on graph g, returning a bool π οΈβ¨
π KEYWORDS π
graph, dot, neato, fdp, circo, twopi, sharp. thatβs the keyword lineup, no cap π
and thatβs the whole page, bestie π«Ά shoutout to the footer energy: source/version 1792256243 and manual gv(3sharp) β periodt π
π
π¦ where this page comes from
- arch rolling: graphviz 16.1.0-2 Β· EPL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms