logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

gv_lua - graph manipulation in lua

Commands

Newgraphs

       New empty graph
              graph_handlegv.graph(name);graph_handlegv.digraph(name);graph_handlegv.strictgraph(name);graph_handlegv.strictdigraph(name);

       New graph from a dot-syntax string or file
              graph_handlegv.readstring(string);graph_handlegv.read(stringfilename);graph_handlegv.read(channel);

       Add new subgraph to existing graph
              graph_handlegv.graph(graph_handle,name);Newnodes

       Add new node to existing graph
              node_handlegv.node(graph_handle,name);Newedges

       Add new edge between existing nodes
              edge_handlegv.edge(tail_node_handle,head_node_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
              edge_handlegv.edge(tail_node_handle,head_name);

       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
              edge_handlegv.edge(tail_name,head_node_handle);

       Add a new edge between named tail  and head nodes which will be induced in the graph if they don't
       already exist
              edge_handlegv.edge(graph_handle,tail_name,head_name);Settingattributevalues

       Set value of named attribute of graph/node/edge - creating attribute if necessary
              stringgv.setv(graph_handle,attr_name,attr_value);stringgv.setv(node_handle,attr_name,attr_value);stringgv.setv(edge_handle,attr_name,attr_value);

       Set value of existing attribute of graph/node/edge (using attribute handle)
              stringgv.setv(graph_handle,attr_handle,attr_value);stringgv.setv(node_handle,attr_handle,attr_value);stringgv.setv(edge_handle,attr_handle,attr_value);Gettingattributevalues

       Get value of named attribute of graph/node/edge
              stringgv.getv(graph_handle,attr_name);stringgv.getv(node_handle,attr_name);stringgv.getv(edge_handle,attr_name);

       Get value of attribute of graph/node/edge (using attribute handle)
              stringgv.getv(graph_handle,attr_handle);stringgv.getv(node_handle,attr_handle);stringgv.getv(edge_handle,attr_handle);Obtainnamesfromhandlesstringgv.nameof(graph_handle);stringgv.nameof(node_handle);stringgv.nameof(attr_handle);Findhandlesfromnamesgraph_handlegv.findsubg(graph_handle,name);node_handlegv.findnode(graph_handle,name);edge_handlegv.findedge(tail_node_handle,head_node_handle);attribute_handlegv.findattr(graph_handle,name);attribute_handlegv.findattr(node_handle,name);attribute_handlegv.findattr(edge_handle,name);Miscgraphnavigatorsreturninghandlesnode_handlegv.headof(edge_handle);node_handlegv.tailof(edge_handle);graph_handlegv.graphof(graph_handle);graph_handlegv.graphof(edge_handle);graph_handlegv.graphof(node_handle);graph_handlegv.rootof(graph_handle);Obtainhandlesofprotonode/edgeforsettingdefaultattributevaluesnode_handlegv.protonode(graph_handle);edge_handlegv.protoedge(graph_handle);Iterators

       Iteration termination tests
              boolgv.ok(graph_handle);boolgv.ok(node_handle);boolgv.ok(edge_handle);boolgv.ok(attr_handle);

       Iterate over subgraphs of a graph
              graph_handlegv.firstsubg(graph_handle);graph_handlegv.nextsubg(graph_handle,subgraph_handle);

       Iterate over supergraphs of a graph (obscure and rarely useful)
              graph_handlegv.firstsupg(graph_handle);graph_handlegv.nextsupg(graph_handle,subgraph_handle);

       Iterate over edges of a graph
              edge_handlegv.firstedge(graph_handle);edge_handlegv.nextedge(graph_handle,edge_handle);

       Iterate over outedges of a graph
              edge_handlegv.firstout(graph_handle);edge_handlegv.nextout(graph_handle,edge_handle);

       Iterate over edges of a node
              edge_handlegv.firstedge(node_handle);edge_handlegv.nextedge(node_handle,edge_handle);

       Iterate over out-edges of a node
              edge_handlegv.firstout(node_handle);edge_handlegv.nextout(node_handle,edge_handle);

       Iterate over head nodes reachable from out-edges of a node
              node_handlegv.firsthead(node_handle);node_handlegv.nexthead(node_handle,head_node_handle);

       Iterate over in-edges of a graph
              edge_handlegv.firstin(graph_handle);edge_handlegv.nextin(node_handle,edge_handle);

       Iterate over in-edges of a node
              edge_handlegv.firstin(node_handle);edge_handlegv.nextin(graph_handle,edge_handle);

       Iterate over tail nodes reachable from in-edges of a node
              node_handlegv.firsttail(node_handle);node_handlegv.nexttail(node_handle,tail_node_handle);

       Iterate over nodes of a graph
              node_handlegv.firstnode(graph_handle);node_handlegv.nextnode(graph_handle,node_handle);

       Iterate over nodes of an edge
              node_handlegv.firstnode(edge_handle);node_handlegv.nextnode(edge_handle,node_handle);

       Iterate over attributes of a graph
              attribute_handlegv.firstattr(graph_handle);attribute_handlegv.nextattr(graph_handle,attr_handle);

       Iterate over attributes of an edge
              attribute_handlegv.firstattr(edge_handle);attribute_handlegv.nextattr(edge_handle,attr_handle);

       Iterate over attributes of a node
              attribute_handlegv.firstattr(node_handle);attribute_handlegv.nextattr(node_handle,attr_handle);Removegraphobjectsboolgv.rm(graph_handle);boolgv.rm(node_handle);boolgv.rm(edge_handle);Layout

       Annotate a graph with layout attributes and values using a specific layout engine
              boolgv.layout(graph_handle,stringengine);Render

       Render a layout into attributes of the graph
              boolgv.render(graph_handle);

       Render a layout to stdout
              boolgv.render(graph_handle,stringformat);

       Render to an open file
              boolgv.render(graph_handle,stringformat,channelfout);

       Render a layout to an unopened file by name
              boolgv.render(graph_handle,stringformat,stringfilename);

       Render to a string result
              stringgv.renderresult(graph_handleing,stringformat);gv.renderresult(graph_handle,stringformat,stringoutdata);

       Render to an open channel
              boolgv.renderchannel(graph_handle,stringformat,stringchannelname);

       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]" )
              stringgv.renderdata(graph_handle,stringformat);

       Writing graph back to file
              boolgv.write(graph_handle,stringfilename);boolgv.write(graph_handle,channel);

       Graph transformation tools
              boolgv.tred(graph_handle);

Introduction

gv_lua  is  a  dynamically  loaded  extension  for  lua  that  provides access to the graph facilities of
       graphviz.

Keywords

       graph, dot, neato, fdp, circo, twopi, lua.

                                                   22 May 2025                                          gv(3lua)

Name

       gv_lua - graph manipulation in lua

Synopsis

       #!/usr/bin/lua
       require('gv')

Usage

See Also