All Projects → evolve75 → Rubytree

evolve75 / Rubytree

Licence: other
A General Purpose Tree Data Structure for Ruby

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Rubytree

Javascript Datastructures Algorithms
📚 collection of JavaScript and TypeScript data structures and algorithms for education purposes. Source code bundle of JavaScript algorithms and data structures book
Stars: ✭ 3,221 (+973.67%)
Mutual labels:  data-structures, tree
Pybktree
Python BK-tree data structure to allow fast querying of "close" matches
Stars: ✭ 117 (-61%)
Mutual labels:  data-structures, tree
Splay Tree
Fast splay-tree data structure
Stars: ✭ 80 (-73.33%)
Mutual labels:  data-structures, tree
Geeksforgeeks Dsa 2
This repository contains all the assignments and practice questions solved during the Data Structures and Algorithms course in C++ taught by the Geeks For Geeks team.
Stars: ✭ 53 (-82.33%)
Mutual labels:  data-structures, tree
Data Structures Algorithms
My implementation of 85+ popular data structures and algorithms and interview questions in Python 3 and C++
Stars: ✭ 273 (-9%)
Mutual labels:  data-structures, tree
Ki
Go language (golang) full strength tree structures (ki in Japanese)
Stars: ✭ 61 (-79.67%)
Mutual labels:  data-structures, tree
Leetcode
LeetCode Solutions: A Record of My Problem Solving Journey.( leetcode题解,记录自己的leetcode解题之路。)
Stars: ✭ 45,650 (+15116.67%)
Mutual labels:  data-structures, tree
C Sharp Algorithms
📚 📈 Plug-and-play class-library project of standard Data Structures and Algorithms in C#
Stars: ✭ 4,684 (+1461.33%)
Mutual labels:  data-structures, tree
Data Structures
Common data structures and algorithms implemented in JavaScript
Stars: ✭ 139 (-53.67%)
Mutual labels:  data-structures, tree
Merkle Tree
Merkle Trees and Merkle Inclusion Proofs
Stars: ✭ 130 (-56.67%)
Mutual labels:  data-structures, tree
Algorithms
Study cases for Algorithms and Data Structures.
Stars: ✭ 32 (-89.33%)
Mutual labels:  data-structures, tree
Libdict
C library of key-value data structures.
Stars: ✭ 234 (-22%)
Mutual labels:  data-structures, tree
Dsa.js Data Structures Algorithms Javascript
🥞Data Structures and Algorithms explained and implemented in JavaScript + eBook
Stars: ✭ 6,251 (+1983.67%)
Mutual labels:  data-structures, tree
Buckets Js
A complete, fully tested and documented data structure library written in pure JavaScript.
Stars: ✭ 1,128 (+276%)
Mutual labels:  data-structures, tree
Algorithms and data structures
180+ Algorithm & Data Structure Problems using C++
Stars: ✭ 4,667 (+1455.67%)
Mutual labels:  data-structures, tree
Data Structures
This repository contains some data structures implementation in C programming language. I wrote the tutorial posts about these data structures on my personal blog site in Bengali language. If you know Bengali then visit my site
Stars: ✭ 82 (-72.67%)
Mutual labels:  data-structures, tree
Java Algorithms Implementation
Algorithms and Data Structures implemented in Java
Stars: ✭ 3,927 (+1209%)
Mutual labels:  data-structures, tree
Algodeck
An Open-Source Collection of 200+ Algorithmic Flash Cards to Help you Preparing your Algorithm & Data Structure Interview 💯
Stars: ✭ 4,441 (+1380.33%)
Mutual labels:  data-structures, tree
Containers
This library provides various containers. Each container has utility functions to manipulate the data it holds. This is an abstraction as to not have to manually manage and reallocate memory.
Stars: ✭ 125 (-58.33%)
Mutual labels:  data-structures, tree
Interview Questions
List of all the Interview questions practiced from online resources and books
Stars: ✭ 187 (-37.67%)
Mutual labels:  data-structures, tree

RubyTree

Gem Version Travis Build Status Code Climate Coverage Status

DESCRIPTION:

RubyTree is a pure Ruby implementation of the generic tree data structure. It provides a node-based model to store named nodes in the tree, and provides simple APIs to access, modify and traverse the structure.

The implementation is node-centric, where individual nodes in the tree are the primary structural elements. All common tree-traversal methods (pre-order, post-order, and breadth-first) are supported.

The library mixes in the Enumerable and Comparable modules to allow access to the tree as a standard collection (iteration, comparison, etc.).

A Binary tree is also provided, which provides the in-order traversal in addition to the other methods.

RubyTree supports importing from, and exporting to JSON, and also supports the Ruby's standard object marshaling.

This is a BSD licensed open source project, and is hosted at github.com/evolve75/RubyTree, and is available as a standard gem from rubygems.org/gems/rubytree.

The home page for RubyTree is at rubytree.anupamsg.me.

WHAT'S NEW:

See History for the detailed Changelog.

See API-CHANGES for the detailed description of API level changes.

GETTING STARTED:

This is a basic usage example of the library to create and manipulate a tree. See the API documentation for more details.

#!/usr/bin/env ruby
#
# example_basic.rb:: Basic usage of the tree library.
#
# Author:  Anupam Sengupta
# Time-stamp: <2013-12-28 12:14:20 anupam>
# Copyright (C) 2013 Anupam Sengupta <[email protected]>
#
# The following example implements this tree structure:
#
#                    +------------+
#                    |    ROOT    |
#                    +-----+------+
#            +-------------+------------+
#            |                          |
#    +-------+-------+          +-------+-------+
#    |  CHILD 1      |          |  CHILD 2      |
#    +-------+-------+          +---------------+
#            |
#            |
#    +-------+-------+
#    | GRANDCHILD 1  |
#    +---------------+

# ..... Example starts.
require 'tree'                 # Load the library

# ..... Create the root node first.
# ..... Note that every node has a name and an optional content payload.
root_node = Tree::TreeNode.new("ROOT", "Root Content")
root_node.print_tree

# ..... Now insert the child nodes.
#       Note that you can "chain" the child insertions to any depth.
root_node << Tree::TreeNode.new("CHILD1", "Child1 Content") << Tree::TreeNode.new("GRANDCHILD1", "GrandChild1 Content")
root_node << Tree::TreeNode.new("CHILD2", "Child2 Content")

# ..... Lets print the representation to stdout.
# ..... This is primarily used for debugging purposes.
root_node.print_tree

# ..... Lets directly access children and grandchildren of the root.
# ..... The can be "chained" for a given path to any depth.
child1       = root_node["CHILD1"]
grand_child1 = root_node["CHILD1"]["GRANDCHILD1"]

# ..... Now retrieve siblings of the current node as an array.
siblings_of_child1 = child1.siblings

# ..... Retrieve immediate children of the root node as an array.
children_of_root = root_node.children

# ..... Retrieve the parent of a node.
parent = child1.parent

# ..... This is a depth-first and L-to-R pre-ordered traversal.
root_node.each { |node| node.content.reverse }

# ..... Remove a child node from the root node.
root_node.remove!(child1)

# .... Many more methods are available. Check out the documentation!

This example can also be found at examples/example_basic.rb.

REQUIREMENTS:

  • Ruby 2.2.x, 2.3.x or 2.4.x

  • Run-time Dependencies:

  • Development dependencies (not required for installing the gem):

    • Bundler for creating the stable build environment
    • Rake for building the package
    • Yard for the documentation
    • RSpec for additional Ruby Spec test files

INSTALL:

To install the gem, run this command from a terminal/shell:

$ gem install rubytree

This should install the gem file for RubyTree. Note that you might need to have super-user privileges (root/sudo) to successfully install the gem.

DOCUMENTATION:

The primary class RubyTree is {Tree::TreeNode}. See the class documentation for an example of using the library.

If the ri documentation was generated during install, you can use this command at the terminal to view the text mode ri documentation:

$ ri Tree::TreeNode

Documentation for the latest released version is available at:

rubytree.anupamsg.me/rdoc

Documentation for the latest git HEAD is available at:

rdoc.info/projects/evolve75/RubyTree

Note that the documentation is formatted using Yard.

DEVELOPERS:

This section is only for modifying RubyTree itself. It is not required for using the library!

You can download the latest released source code as a tar or zip file, as mentioned above in the installation section.

Alternatively, you can checkout the latest commit/revision from the Version Control System. Note that RubyTree's primary SCM is git and is hosted on github.com.

Using the git Repository

The git repository is available at github.com/evolve75/RubyTree.

For cloning the git repository, use one of the following commands:

$ git clone git://github.com/evolve75/RubyTree.git

or

$ git clone http://github.com/evolve75/RubyTree.git

Setting up the Development Environment

RubyTree uses Bundler to manage its dependencies. This allows for a simplified dependency management, for both run-time as well as during build.

After checking out the source, run:

$ gem install bundler
$ bundle install
$ rake test
$ rake doc:yard
$ rake gem:package

These steps will install any missing dependencies, run the tests/specs, generate the documentation, and finally generate the gem file.

Note that the documentation uses Yard, which will be downloaded and installed automatically by Bundler.

ACKNOWLEDGMENTS:

A big thanks to the following contributors for helping improve RubyTree:

  1. Dirk Breuer for contributing the JSON conversion code.
  2. Vincenzo Farruggia for contributing the (sub)tree cloning code.
  3. Eric Cline for the Rails JSON encoding fix.
  4. Darren Oakley for the tree merge methods.
  5. Youssef Rebahi-Gilbert for the code to check duplicate node names in the tree (globally unique names).
  6. Paul de Courcel for adding the postordered_each method.
  7. Jen Hamon for adding the from_hash method.
  8. Evan Sharp for adding the rename and rename_child methods.
  9. Aidan Steele for performance improvements to is_root? and node_depth.
  10. Marco Ziccadi for adding the path_as_string and path_as_array methods.

LICENSE:

RubyTree is licensed under the terms of the BSD license. See LICENSE.md for details.

{include:file:LICENSE.md}

    __       _           _
   /__\_   _| |__  _   _| |_ _ __ ___  ___
  / \// | | | '_ \| | | | __| '__/ _ \/ _ \
 / _  \ |_| | |_) | |_| | |_| | |  __/  __/
 \/ \_/\__,_|_.__/ \__, |\__|_|  \___|\___|
                  |___/

Bitdeli Badge

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].