Welcome to a DSL for creating Mikado Graphs using GraphViz.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install mikado_graph
Ensure you have GraphViz installed. On macOS you can install it using Homebrew with the following command:
brew install graphviz
You can use this gem's DSL in the following way to create a Mikado Graph generator definition file:
require "mikado_graph" MikadoGraph::Generator.define do state("State A").with_prerequisites do state("State B").with_prerequisites do state("State D") state("State E") end state("State C").with_prerequisites do state("State F") state("State G") end end end.generate("png", "img/example_usage_vertical.png") # generate takes GraphViz format and output path
You can also use the shorthand
with_prerequisitesfor defining prerequisite dependencies between states.
Save this file to
example_usage_vertical.rb and then you can then execute this file in the terminal using:
This will utilize GraphViz to create this PNG output of the above Mikado Graph generator definition:
NOTE: If you don't provide any parameters to
generate, it'll default to a
dot output in the STDOUT.
If you want to instead do a horizontal orientation of your graph, simply provide the direction flag to
#generate like so:
Here is an example usage:
require "mikado_graph" MikadoGraph::Generator.define do state("State A").with_prerequisites do state("State B").with_prerequisites do state("State D") state("State E") end state("State C").with_prerequisites do state("State F") state("State G") end end end.generate(format: "png", path: "img/example_usage_horizontal.png", direction: :horizontal)
This will generate this graph:
After checking out the repo, run
bin/setup to install dependencies. Then, run
rake spec to run the tests. You can also run
bin/console for an interactive prompt that will allow you to experiment.
direnv to speed development.
Bug reports and pull requests are welcome on GitHub at https://github.com/snasirca/mikado-graph-generator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.