Tree data structure in C#

前端 未结 20 2192
梦如初夏
梦如初夏 2020-11-22 08:30

I was looking for a tree or graph data structure in C# but I guess there isn\'t one provided. An Extensive Examination of Data Structures Using C# 2.0 explains a bit about w

20条回答
  •  一生所求
    2020-11-22 09:01

    I create a Node class that could be helpfull for other people. The class has properties like:

    • Children
    • Ancestors
    • Descendants
    • Siblings
    • Level of the node
    • Parent
    • Root
    • Etc.

    There is also the possibility to convert a flat list of items with an Id and a ParentId to a tree. The nodes holds a reference to both the children and the parent, so that makes iterating nodes quite fast.

提交回复
热议问题