Beispiel #1
0
        /// <summary>
        /// Remove a neuron from the network, including its connections.
        /// </summary>
        public Neuron RemoveNode(Neuron targetNeuron)
        {
            var genesToRemove = Genes.Where(x => x.StartNode == targetNeuron || x.EndNode == targetNeuron);

            foreach (var gene in genesToRemove)
            {
                gene.Disconnect();
            }

            Genes = Genes.Except(genesToRemove).ToList();
            Neurons.Remove(targetNeuron);
            return(targetNeuron);
        }