/// <summary>
        ///
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="p_p1">probability of value=1 given parent.value=1</param>
        /// <param name="p_p2">probability of value=1 given parent.value=0</param>
        public DependenceNode(DependenceNode parent, double p_p0, double p_p1, String name)
        {
            children    = new List <DependenceNode>();
            this.parent = parent;
            if (parent != null)
            {
                parent.addChild(this);
            }
            this.featureName = name;

            this.p_p0 = p_p0;
            this.p_p1 = p_p1;
        }
        public static DependenceNode generateRandomTree(int size, int maxNodeChildren = 3)
        {
            int nameIndex = 0;


            DependenceNode firstNode = new DependenceNode(null, rndGen.NextDouble(), rndGen.NextDouble(), "n" + nameIndex);

            List <DependenceNode> lowestLayer = new List <DependenceNode>();
            List <DependenceNode> newLayer    = new List <DependenceNode>();

            lowestLayer.Add(firstNode);
            size--;
            nameIndex++;

            while (size > 0)
            {
                foreach (DependenceNode lowestNode in lowestLayer)
                {
                    int randomNodes = rndGen.Next(0, maxNodeChildren);
                    for (int i = 0; i < randomNodes && size > 0; i++)
                    {
                        newLayer.Add(new DependenceNode(lowestNode, rndGen.NextDouble(), rndGen.NextDouble(), "n" + nameIndex));
                        size--;
                        nameIndex++;
                    }
                }
                if (newLayer.Count > 0)
                {
                    lowestLayer = newLayer;
                    newLayer    = new List <DependenceNode>();
                }
            }



            return(firstNode);
        }
 public void addChild(DependenceNode dn)
 {
     children.Add(dn);
 }