Accord.Controls.DecisionTreeView.convert C# (CSharp) Method

convert() private method

private convert ( DecisionNode node ) : TreeNode
node DecisionNode
return TreeNode
        private TreeNode convert(DecisionNode node)
        {
            TreeNode treeNode = (codebook == null) ?
                new TreeNode(node.ToString()) :
                new TreeNode(node.ToString(codebook));


            if (!node.IsLeaf)
            {
                foreach (var child in node.Branches)
                    treeNode.Nodes.Add(convert(child));

                return treeNode;
            }


            if (codebook == null || !node.Output.HasValue)
            {
                treeNode.Nodes.Add(new TreeNode(node.Output.ToString()));
                return treeNode;
            }

            int index = node.Parent.Branches.AttributeIndex;
            var attrib = treeSource.Attributes[index];

            if (attrib.Nature != DecisionVariableKind.Discrete)
            {
                treeNode.Nodes.Add(new TreeNode(node.Output.ToString()));
                return treeNode;
            }

            string value = codebook.Translate(attrib.Name, node.Output.Value);
            treeNode.Nodes.Add(new TreeNode(value));
            return treeNode;
        }
    }