gv(3java)

πŸ“¦
version 14.1.4 Β· 4 versions
, in fedora 44

🌸 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