コード例 #1
0
ファイル: IslandConnections.cs プロジェクト: jswk/GA-BO
        private bool _debugMode = true; //change to false if sure than args are correct

        #endregion Fields

        #region Constructors

        public IslandConnections(List<int>[] connection, Island[] islands)
        {
            // create digraf where every vertex is island[i], and connections corresponds to adjacence list given in 'connection'

            if (_debugMode == true)
            {
                if (connection.Length != islands.Length)
                {
                    throw new Exception("Both array args must have the same length");
                }

                for (int i = 0; i < connection.Length; i++)
                {
                    if (connection[i].Any(num => num >= connection.Length))
                    {
                        throw new Exception("Found wrong connection, index of island " + i + " out of range");
                    }

                    if (connection[i].Contains(i))
                    {
                        throw new Exception("Found wrong connection, island -> island for island = " + i);
                    }
                }
            }

            di_graph = new DirectedGraph(islands, connection);
        }
コード例 #2
0
ファイル: IslandSupervisor.cs プロジェクト: jswk/GA-BO
 public void exchangeIndividuals(Island from, List<IIndividual> individuals)
 {
     lock (connections)
     {
         foreach (Island island in connections.getConnections(from))
             island.welcomeNewIndividuals(individuals);
     }
 }
コード例 #3
0
ファイル: DirectedGraph.cs プロジェクト: jswk/GA-BO
        public List<Island> GetConnections(Island island)
        {
            if (!_islands.Contains(island))
            {
                throw new Exception("Island does not exist");
            }

            int index = Array.IndexOf(_islands, island);

            List<Island> toReturn = new List<Island>();
            foreach (int i in _connections[index])
            {
                toReturn.Add(_islands[i]);
            }
            return toReturn;
        }
コード例 #4
0
ファイル: DirectedGraph.cs プロジェクト: jswk/GA-BO
        public List <Island> GetConnections(Island island)
        {
            if (!_islands.Contains(island))
            {
                throw new Exception("Island does not exist");
            }

            int index = Array.IndexOf(_islands, island);

            List <Island> toReturn = new List <Island>();

            foreach (int i in _connections[index])
            {
                toReturn.Add(_islands[i]);
            }
            return(toReturn);
        }
コード例 #5
0
ファイル: DirectedGraph.cs プロジェクト: jswk/GA-BO
 public DirectedGraph(Island[] islands, List<int>[] connection)
 {
     this._islands = islands;
     this._connections = connection;
 }
コード例 #6
0
 public List <Island> getConnections(Island island)
 {
     //return all X adjacent to island (such as: island -> X)
     return(di_graph.GetConnections(island));
 }
コード例 #7
0
ファイル: IslandConnections.cs プロジェクト: jswk/GA-BO
 public List<Island> getConnections(Island island)
 {
     //return all X adjacent to island (such as: island -> X)
     return di_graph.GetConnections(island);
 }