GithubHelp home page GithubHelp logo

skywalker97 / forest Goto Github PK

View Code? Open in Web Editor NEW

This project forked from matuskysel/forest

0.0 1.0 0.0 203 KB

Forest is an open source, template library of tree data structures written in C++11.

License: MIT License

CMake 0.13% C++ 99.87%

forest's Introduction

forest logo

CircleCI

Forest is an open source, template library of tree data structures written in C++11.

Installation

Linux / macOS

$ git clone https://github.com/xorz57/forest.git
$ cd forest
$ mkdir build
$ cd build
$ cmake ..
$ make install

Example Code

Forest is best explained through examples. The following source code generates a red black tree, inserts 7 nodes and then performs an in order traversal.

#include <forest/red_black_tree.h>

int main() {
        // Generate a binary search tree for nodes of integer keys and values
        forest::red_black_tree <int, int> red_black_tree;

        // Insert 7 nodes in the form of a (key, value) pair
        red_black_tree.insert(4,0);
        red_black_tree.insert(2,0);
        red_black_tree.insert(90,0);
        red_black_tree.insert(3,100);
        red_black_tree.insert(0,0);
        red_black_tree.insert(14,0);
        red_black_tree.insert(45,0);

        // Perform an in order traversal
        red_black_tree.in_order_traversal();

        // Generate a .dot file representing the Red Black Tree
        red_black_tree.graphviz("red_black_tree.dot");

        return 0;
}

Graph Visualization using Graphviz

Forest provides an easy way to visualize tree data structures using the graphviz member function. When this function is called, a DOT file describing the data structure graph is created. In order to be able to generate an image of the graph you must install Graphviz. The generated DOT file can be feed to the dot tool (provided by Graphviz) which in turn will generate an image for the graph.

$ dot red_black_tree.dot -Tpng > red_black_tree.png

This is the graph visualization of the above example code, generated with the dot tool (provided by Graphviz).

Red Black Tree Graph

Refer to the Quick Start Guide page for further information and examples.

forest's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.