public Dendrite CreateDendrite()
        {
            Dendrite d = new Dendrite();

            d.Id        = Guid.NewGuid().ToString();
            d.Weight    = 0f;
            d.NewWeight = null;
            Dendrites.Add(d);
            return(d);
        }
        public static NeuralNetwork Create(int[] layer_definition, bool include_bias_neurons)
        {
            NeuralNetwork nn = new NeuralNetwork();



            List <Neuron> PreviousLayerNeurons = new List <Neuron>();

            for (int t = 1; t <= layer_definition.Length; t++)
            {
                //Create this layers neurons
                List <Neuron> ThisLayerNeurons            = new List <Neuron>();
                int           NumberOfNeuronsForThisLayer = layer_definition[t - 1];
                for (int nc = 1; nc <= NumberOfNeuronsForThisLayer; nc++)
                {
                    Neuron n = nn.CreateNeuron();
                    ThisLayerNeurons.Add(n);
                }



                //If there are neurons in the "PreviousLayerNeurons" then connect the new ones to those
                if (PreviousLayerNeurons.Count > 0)
                {
                    foreach (Neuron tn in ThisLayerNeurons)
                    {
                        foreach (Neuron pn in PreviousLayerNeurons)
                        {
                            Dendrite d = nn.CreateDendrite();
                            d.InputNeuronId  = pn.Id;
                            d.OutputNeuronId = tn.Id;
                        }
                    }
                }


                //Reset for next round
                PreviousLayerNeurons.Clear();
                PreviousLayerNeurons.AddRange(ThisLayerNeurons);
                ThisLayerNeurons.Clear();


                //Add a bias neuron if asked to (this has to be done after the full connections have been made in the previous step.
                if (include_bias_neurons == true)
                {
                    if (t != layer_definition.Length)     //If it is not the last layer
                    {
                        Neuron bn = nn.CreateNeuron();
                        bn.InputValue   = 1;
                        bn.IsBiasNeuron = true;
                        PreviousLayerNeurons.Add(bn);
                    }
                }
            }


            //Randomize all weights
            nn.RandomizeAllWeights();

            return(nn);
        }