MultiwayTree 1.1.0

dotnet add package MultiwayTree --version 1.1.0
NuGet\Install-Package MultiwayTree -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MultiwayTree" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MultiwayTree --version 1.1.0
#r "nuget: MultiwayTree, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MultiwayTree as a Cake Addin
#addin nuget:?package=MultiwayTree&version=1.1.0

// Install MultiwayTree as a Cake Tool
#tool nuget:?package=MultiwayTree&version=1.1.0

MultiwayTree

Summary

This repository aims to provide a simple, concise, flexible, and well-tested multiway tree nuget package for dotnet core.

Background

multiway tree is a tree that can have more than two children. A multiway tree of order k (or an k-way or k-ary tree) is one in which a tree can have k children. Learn more about multiway trees

Usage
  1. Install the nuget package from nuget.org with your favorite package manager.
  2. Instantiate a MultiwayTree<T> where T is your desired tree node data Type.
    • e.g. new MultiwayTree<int>(0) will have a Data property of Type int with value 0.
  3. Add child nodes to your tree.
    • If myTree is a MultiwayTree<int>, myTree.AddChild(1) or myTree.AddChild(new MultiwayTree<int>(1)) will have the same effect.
    • Note: T must be the same Type for all nodes of a tree i.e. if myTree is a MultiwayTree<int>, then myTree.AddChild("this is a string") is not possible.
  4. Instantiate your tree traverser.
    • Option 1: Instantiate a GenericMultiwayTreeTraverser.
      • Best for simple node visitation logic.
      • Expects two type parameters:
        1. the Type of Data in the tree(s) you'll be traversing, and
        2. the Type of the return value of your node visitation function.
      • Expects a single constructor parameter: An async delegate function defining what it means to visit a node. Lambda syntax is convenient for this e.g.
          var myTraverser = new GenericMultiwayTreeTraverser<int, string>(
          	async (dataInt, cumulativeResultString) => {
          		return (cumulativeResultString ?? string.Empty) 
          			+ dataInt.ToString();
          	}
          );
        
        • Note: The node visitation function expects two parameters:
          1. the Data property value of the current node, and
          2. the return value from the most recent node visitation function invocation. This will be null when you visit the first node if T is nullable.
    • Option 2: Implement your own tree traversal class.
      • Best for more complex node visitation logic, and works well with IoC pattern.
      • Extend AbstractMultiwayTreeTraverser e.g.
        	public class MyTreeTraverser : AbstractMultiwayTreeTraverser<int, string>
      
      • Override and implement VisitNodeAsync with whatever logic you want.
        • VisitNodeAsync must return a NodeVisitResult which has 2 properties:
          1. a TValue Value where TValue is the second Type parameter you set when extending AbstractMultiwayTreeTraverser, and
          2. a bool ContinueTraversing which is only relevant when your traversal type is TraversalType.LevelOrderSearch (see below).
  5. Traverse your tree.
    • 4 traversal types are provided via an enum:
      1. TraversalType.LevelOrder
      2. TraversalType.PostOrder
      3. TraversalType.PreOrder
      4. TraversalType.LevelOrderSearch
    • All traversal types except LevelOrderSearch will visit every node in the tree. LevelOrderSearch will stop traversing the tree when the ContinueTraversing property of the VisitNodeResult returned from visiting the most recent node is false.
    • Example:
     	var result = await myTraverser.TraverseAsync(myTree, TraversalType.PreOrder)
    
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 152 6/28/2023
1.0.0 181 3/25/2023