mruby-graphviz — Graphviz binding for mruby

This mruby gem is a Graphviz’s cgraph library (and gvc) binding for mruby. The API is aimed to be fluent in Ruby way. At the moment, the functionalities are somewhat limited, though overall features are equivalent to the gv gem which is listed at the Graphviz website.

This mgem requires at least 13.0.0 version of Graphviz (because of breaking changes at this version over C API).

Links: Project repository

Install by mrbgems

Add conf.gem line to build_config.rb:

MRuby::Build.new do |conf|
  conf.gem :git => 'https://codeberg.org/gemmaro/mruby-graphviz', branch: 'main'
end

Example

graph = Graphviz::Graph.new('graph_name', directed: true, strict: true)
tail = graph.find_or_create_node('tail_node')
head = graph.find_or_create_node('head_node')
graph.find_or_create_edge(tail, head)
Graphviz::Context.new
  .create_layout(graph, 'dot')
  .write('/path/to/result.png', 'png')

References

The Library Usage page, especially: “Cgraph library tutorial”, “Using Graphviz as a library”, “cgraph”, and “gvc”.

Related Works

There is gv gem for CRuby (introduced on official website). There are also too many RubyGems including ruby-graphviz, and most of them are written in pure Ruby.

License

This mgem is released under the GPL3+ license. Please refer to the COPYING file for details:

Copyright © 2026 gemmaro

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see www.gnu.org/licenses/.