8000 GitHub - changzhihao/TreeLib: A .Net Standard Library with Generic methods to traverse k-ary trees in any order required.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A .Net Standard Library with Generic methods to traverse k-ary trees in any order required.

License

Notifications You must be signed in to change notification settings

changzhihao/TreeLib

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build status Release < 8C7A img src="https://camo.githubusercontent.com/4b5cbb9cd033ca1930b417919b8335d6d1db1be238f26fc9bf938c6e459b6e79/68747470733a2f2f696d672e736869656c64732e696f2f6e756765742f64742f4469726b737465722e547265654c69622e737667" alt="NuGet" data-canonical-src="https://img.shields.io/nuget/dt/Dirkster.TreeLib.svg" style="max-width: 100%;">

TreeLib

This project provides a:

  • .Net Standard Library (1.4, 1.6, 2.0) or a
  • .Net framework 4.0 Library

with Generic methods to traverse k-ary trees in different orders (Post-Order, Pre-Order, Level-Order) of traversal. This implementation includes scalable algorithms that return IEnumerable<T> to make parsing large tree structures a piece of cake, as well, as Generic Exception handling to ensure that traversal algorithms complete despite unexpected errors on some nodes.

Review demo projects:

Implementing something as complicated as a Post-Order traversal algorithm requires just:

  • a project reference,
  • a LINQ statement to find each set of children in the tree,
  • and a simple for each loop to implement the operation on each tree node:
Console.WriteLine("(Depth First) PostOrder Tree Traversal V3");
items = TreeLib.Depthfirst.Traverse.PostOrder(root, i => i.Children);

foreach (var item in items)
{
  Console.WriteLine(item.GetPath());
}

This pattern leads to a clear-cut separation of:

  • the traversal algorithm and
  • the operations performed on each tree node (e.g.: Console.WriteLine(item.GetPath());).

The project in this repository contains a demo console project to demo its usage in more detail.

Supported Generic Traversal Methods

Breadth First

Level Order

See TreeLib.BreadthFirst.Traverse.LevelOrder implementation for:

Depth First

PreOrder

See TreeLib.BreadthFirst.Traverse.PreOrder implementation for:

Postorder

See TreeLib.BreadthFirst.Traverse.Postorder implementation for:

Tip

About

A .Net Standard Library with Generic methods to traverse k-ary trees in any order required.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 98.9%
  • Batchfile 1.1%
0