Ejemplo n.º 1
0
        public void Disconnect(Neural other, string connToType, string connFromType = null)
        {
            var connToTypeStr = connToType;
            var connFromTypeStr = connFromType;

            this.ConnectedTo.Get(connToTypeStr).Remove(other);

            if (connFromType == null)
                return;
            other.ConnectedFrom.Get(connFromTypeStr).Remove(this);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 连接两个神经元
        /// </summary>
        /// <param name="other">另一个要连接的神经元</param>
        /// <param name="connToType">第一个神经元连向第二个神经元连接类型</param>
        /// <param name="connFromType">第二个神经元连向第一个神经元的连接类型</param>
        public void Connect(Neural other, string connToType, string connFromType = null)
        {
            var connToTypeStr = connToType;
            var connFromTypeStr = connFromType;

            this.ConnectedTo.SetDefault(connToTypeStr).Add(other);

            if (connFromType == null)
                return;
            other.ConnectedFrom.SetDefault(connFromTypeStr).Add(this);
        }
Ejemplo n.º 3
0
 public List<string> GetConnections(Neural targetNeu)
 {
     var result = new List<string>();
     foreach (var klstp in this.ConnectedTo)
     {
         if (klstp.Value.Contains(targetNeu))
             result.Add(klstp.Key);
     }
     foreach (var klstp in this.ConnectedFrom)
     {
         if (klstp.Value.Contains(targetNeu))
             result.Add(klstp.Key);
     }
     return result;
 }