gv(3java)
πΈ NAME πΈ
okay so bestie, this page is all about gv_java β which is, and I quote, graph manipulation in java. that's the whole name. no notes, it does exactly what it says. π
β¨ SYNOPSIS β¨
System.loadLibrary("gv");
that's it. that's the whole vibe check. load the library and you're in. π
π USAGE π
π¦ INTRODUCTION π¦
gv_java is a dynamically loaded extension for java that gives you access to the graph facilities of graphviz. literally all of the graph stuff. the whole toolbox. slay. π«Ά
π COMMANDS π
π± New graphs π±
New empty graph β start from nothing, main character energy:
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);
New graph from a dot-syntax string or file β bring your own graph, we love a read:
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);
Add new subgraph to existing graph β nesting era:
SWIGTYPE_p_Agraph_t gv.graph (SWIGTYPE_p_Agraph_t g, string name);
πΏ New nodes πΏ
Add new node to existing graph β plop a node in there:
SWIGTYPE_p_Agnode_t gv.node (SWIGTYPE_p_Agraph_t g, string name);
π New edges π
Add new edge between existing nodes β both ends already exist, easy:
SWIGTYPE_p_Agedge_t gv.edge (SWIGTYPE_p_Agnode_t t, SWIGTYPE_p_Agnode_t h);
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 β the head node gets summoned into existence if it's not already there. manifesting β¨
SWIGTYPE_p_Agedge_t gv.edge (SWIGTYPE_p_Agnode_t t, string hname);
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 β same deal but the tail is the one that gets conjured:
SWIGTYPE_p_Agedge_t gv.edge (string tname, SWIGTYPE_p_Agnode_t h);
Add a new edge between named tail and head nodes which will be induced in the graph if they don't already exist β neither end exists yet? doesn't matter, both get induced:
SWIGTYPE_p_Agedge_t gv.edge (SWIGTYPE_p_Agraph_t g, string tname, string hname);
π Setting attribute values π
Set value of named attribute of graph/node/edge - creating attribute if necessary β if the attribute isn't there yet, it gets created. we love a flexible queen:
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);
Set value of existing attribute of graph/node/edge (using attribute handle) β this flavor wants the attribute handle instead of a name:
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);
π Getting attribute values π
Get value of named attribute of graph/node/edge β ask by name, receive a string:
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);
Get value of attribute of graph/node/edge (using attribute handle) β same energy, handle edition:
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);
π§ Obtain names from handles π§
you got a handle, now you want the name back. iconic round trip:
string gv.nameof (SWIGTYPE_p_Agraph_t g);
string gv.nameof (SWIGTYPE_p_Agnode_t n);
string gv.nameof (SWIGTYPE_p_Agsym_t a);
π¦ Find handles from names π¦
going the other direction β hand over a name, get a handle:
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);
π« Misc graph navigators returning handles π«
little wanderers that hand you handles back:
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);
β Obtain handles of proto node/edge for setting default attribute values β
get the proto node or proto edge so you can set defaults. the template besties:
SWIGTYPE_p_Agnode_t gv.protonode (SWIGTYPE_p_Agraph_t g);
SWIGTYPE_p_Agedge_t gv.protoedge (SWIGTYPE_p_Agraph_t g);
π Iterators π
Iteration termination tests β the "are we done yet" check:
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);
Iterate over subgraphs of a graph β walk the subgraphs:
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);
Iterate over supergraphs of a graph (obscure and rarely useful) β the original page literally calls this one obscure and rarely useful, so. take that as you will π
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);
Iterate over edges of a graph β all the edges, from the graph's perspective:
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);
Iterate over outedges of a graph β outgoing ones:
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);
Iterate over edges of a node β now from a node's perspective:
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);
Iterate over out-edges of a node β outgoing 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);
Iterate over head nodes reachable from out-edges of a node β follow the out-edges to the heads:
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);
Iterate over in-edges of a graph β incoming edges of a graph. okay this one is written exactly like this on the page, with firstin taking a graph and nextin taking a node, and we are simply passing it along verbatim, no edits, no notes π
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);
Iterate over in-edges of a node β incoming edges of a node, written exactly like this too:
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);
Iterate over tail nodes reachable from in-edges of a node β follow the in-edges back to the tails:
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);
Iterate over nodes of a graph β the classic:
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);
Iterate over nodes of an edge β an edge's two endpoints:
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);
Iterate over attributes of a graph β the graph's attribute handles:
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);
Iterate over attributes of an edge β the edge's attribute handles:
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);
Iterate over attributes of a node β the node's attribute handles:
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);
Remove graph objects β yeet a graph, a node, or an edge:
bool gv.rm (SWIGTYPE_p_Agraph_t g);
bool gv.rm (SWIGTYPE_p_Agnode_t n);
bool gv.rm (SWIGTYPE_p_Agedge_t e);
π Layout π
Annotate a graph with layout attributes and values using a specific layout engine β pick your engine and let it cook:
bool gv.layout (SWIGTYPE_p_Agraph_t g, string engine);
π¨ Render π¨
Render a layout into attributes of the graph β the render goes back into the graph's own attributes:
bool gv.render (SWIGTYPE_p_Agraph_t g);
Render a layout to stdout β straight to the terminal:
bool gv.render (SWIGTYPE_p_Agraph_t g, string format);
Render to an open file β you already have the file open, so here you go:
bool gv.render (SWIGTYPE_p_Agraph_t g, string format, SWIGTYPE_p_FILE fout);
Render a layout to an unopened file by name β just hand it a filename:
bool gv.render (SWIGTYPE_p_Agraph_t g, string format, string filename);
Render to a string result β the page gives you two flavors, exactly as written:
string gv.renderresult (SWIGTYPE_p_Agraph_t ing, string format);
gv.renderresult (SWIGTYPE_p_Agraph_t g, string format, string outdata);
Render to an open channel β channel name in, render out:
bool gv.renderchannel (SWIGTYPE_p_Agraph_t g, string format, string channelname);
Render a layout to a malloc'ed string, to be free'd by the caller
β οΈ deprecated - too easy to leak memory β οΈ
like, the page is begging you. it's giving memory leak. but also:
(still needed for "eval [gv::renderdata $G tk]" )
string gv.renderdata (SWIGTYPE_p_Agraph_t g, string format);
π Writing graph back to file π
Write it out to a filename, or to a FILE you already have open:
bool gv.write (SWIGTYPE_p_Agraph_t g, string filename);
bool gv.write (SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_FILE f);
π§ Graph transformation tools π§
tred β the transformation tool on this page:
bool gv.tred (SWIGTYPE_p_Agraph_t g);
π KEYWORDS π
graph, dot, neato, fdp, circo, twopi, java.
that's the whole page bestie, every last signature, no cap. this was gv(3java), dated 21 March 2026, and honestly? she ate. go build something with nodes in it. π
β¨π¦
π¦ where this page comes from
- fedora 44: graphviz-java 14.1.4-2.fc44 Β· epl-1.0 AND cpl-1.0 AND bsd-3-clause AND mit AND gpl-3.0-or-later WITH bison-exception-2.2 AND apache-1.1 AND lgpl-2.0-or-later WITH libtool-exception AND smlnj AND hpnd-uc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms