0.0
No release in over 3 years
A tiny Ruby library for generating finite state machine (automaton) diagrams as SVG.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 3.4
 Project Readme

Graphomaton Gem Version CI

A tiny Ruby library for generating finite state machine (automaton) diagrams as SVG.

Image

Installation

Add this line to your application's Gemfile:

gem 'graphomaton'

And then execute:

bundle install

Or install it yourself as:

gem install graphomaton

Usage

require 'graphomaton'

# Create a DFA that accepts strings ending with 'ab'
automaton = Graphomaton.new

# Add states
automaton.add_state('q0')
automaton.add_state('q1')
automaton.add_state('q2')

# Set initial and final states
automaton.set_initial('q0')
automaton.add_final('q2')

# Add transitions
automaton.add_transition('q0', 'q1', 'a')
automaton.add_transition('q1', 'q2', 'b')
automaton.add_transition('q0', 'q0', 'b')
automaton.add_transition('q1', 'q0', 'a')
automaton.add_transition('q2', 'q0', 'b')
automaton.add_transition('q2', 'q1', 'a')

# Save as SVG
automaton.save_svg('output.svg')

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ydah/graphomaton.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Graphomaton project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.