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_ruby - graph manipulation in ruby

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_ruby  is  a  dynamically  loaded  extension  for  ruby that provides access to the graph facilities of
       graphviz.

Keywords

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

                                                   22 May 2025                                         gv(3ruby)

Name

       gv_ruby - graph manipulation in ruby

Synopsis

       #!/usr/bin/ruby
       require 'gv'

Usage

See Also