Example #1
0
 /// <summary>
 /// Show the node and all its child
 /// </summary>
 /// <param name="parent">the node to show</param>
 public void showNode(Node parent)
 {
     counter = 1;
     Console.Clear();
     Console.WriteLine(parent.Name);
     foreach (Node child in parent.Children)
     {
         showNode(child," ");
     }
 }
Example #2
0
 /// <summary>
 /// Show the node and all its child and by adding spaces to show in the console who's child of who.
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="add"></param>
 public void showNode(Node parent, string add)
 {
     Console.WriteLine(add+parent.Choose+"->"+parent.Name);
     
     foreach (Node child in parent.Children)
     {
         showNode(child,"  "+add);
         counter++;
         if (counter > 19)
         {
             Console.WriteLine("Show more... press any key");
             Console.ReadKey();
             counter = 0;
         }  
     }
 }
Example #3
0
        /// <summary>
        /// return the node that may contains child node
        /// </summary>
        /// <param name="data">dataset</param>
        /// <param name="name">list of column names</param>
        /// <returns></returns>
        public Node getNode(List<string[]> data, List<string> name)
        {
            int index = getMinInfo(data, name);
            List<string> vars = getVariables(data, index);

            List<string[]> dataCopy = new List<string[]>(data);
            List<string> nameCopy = new List<string>(name);

            List<string> newName = new List<string>();
            List<string[]> newData = new List<string[]>();
            newName = getNewName(nameCopy, index);
            Node parent = new Node(name[index]);
            foreach(string var in vars)
            {
                newData = getNewData(dataCopy, var, index);
                if (newData.Count != 0)
                {
                    if (checkData(newData))
                    {
                        Node child = new Node(newData[0][newData[0].Length - 1]);
                        child.Choose = var;
                        parent.Children.Add(child);
                    }
                    else
                    {
                        if(newData[0].Length != 1)
                        {
                            Node child = getNode(newData, newName);
                            child.Choose = var;
                            parent.Children.Add(child);
                        }
                        else
                        {
                            string res = newData[0][newData[0].Length - 1];
                            int nbB = getCount(newData, res, newData[0].Length - 1);
                            int nbData = newData.Count;
                            double percentage = Math.Round((double)nbB*100.0 / nbData,1);
                            Node child = new Node("undecided with " + percentage + "% of " + res);
                            child.Choose = var;
                            parent.Children.Add(child);
                        }
                       
                    }
                }
            }
            return parent;
        }