ryanreadbooks / bitreevis

bitreevis is a tool which helps visualize the binary tree structure in golang.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bitreevis

Go Reference

This repo is a tool which helps visualize binary tree structure in Golang. It is useful when debugging a program with binary tree structure.

Prerequisites

Installation

With Go module support (Go 1.11+), simply add the following import

import "github.com/ryanreadbooks/bitreevis"

to your code. Or you can use the following the get this package.

$ go get -u github.com/ryanreadbooks/bitreevis

Usage

Quick start

Details can be found in examples/svg_demo.go.

bitreevis.BiNode

In order to visualize your own binary tree, you should implement the bitreevis.BiNode interface. Then you can use bitreevis.VisAsSvg() function to visualize the binary tree in svg graphic format.

bitreevis.RenderOption

bitreevis.RenderOption is used to define the output style of the visualization. The size of nodes, color of nodes, the width of edges, etc. can be customized by setting option.

svg-demo

Private color for each node

If you want to paint different colors for different nodes. You should do the extra work after implementing the bitreevis.BiNode interface above, which is implementing the bitreevis.PaintableBiNode. For example, if you want to visualize a red-black tree, you can use private color for each node. See example.

rb-tree-svg

Learn more

About

bitreevis is a tool which helps visualize the binary tree structure in golang.

License:Apache License 2.0


Languages

Language:Go 100.0%