LoginSignup
4
3

More than 5 years have passed since last update.

Gvizで二分木データ構造の図を作成する

Last updated at Posted at 2014-10-07

gvizをインストール

$ gem install gviz

ソースコード

graph.rb
# coding: utf-8

require 'gviz'

gv = Gviz.new

gv.add %i(two three) => :one
gv.add %i(five six) => :two
gv.add %i(seven eight) => :three
gv.add %i(nine ten) => :five
gv.add %i(eleven twelve) => :six
gv.add %i(thirteen fourteen) => :seven
gv.add %i(fifteen sixteen) => :eight

gv.save :sample, :png

出力結果

sample.png

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3