Beispiel #1
0
        static TrainMap InitializeProgram()
        {
            #region InitializeProgram
            // inicializando o grafo com estações e rotas pré definidas
            var stationA = new TrainStation('A');
            var stationB = new TrainStation('B');
            var stationC = new TrainStation('C');
            var stationD = new TrainStation('D');
            var stationE = new TrainStation('E');

            var edgeAB = new TrainConnection(5, stationA, stationB);
            var edgeBC = new TrainConnection(4, stationB, stationC);
            var edgeCD = new TrainConnection(8, stationC, stationD);
            var edgeDC = new TrainConnection(8, stationD, stationC);
            var edgeDE = new TrainConnection(6, stationD, stationE);
            var edgeAD = new TrainConnection(5, stationA, stationD);
            var edgeCE = new TrainConnection(2, stationC, stationE);
            var edgeEB = new TrainConnection(3, stationE, stationB);
            var edgeAE = new TrainConnection(7, stationA, stationE);

            stationA.AddConnections(new List <TrainConnection> {
                edgeAB, edgeAD, edgeAE
            });
            stationB.AddConnection(edgeBC);
            stationC.AddConnections(new List <TrainConnection> {
                edgeCD, edgeCE
            });
            stationD.AddConnections(new List <TrainConnection> {
                edgeDC, edgeDE
            });
            stationE.AddConnection(edgeEB);

            var trainMap = new TrainMap(new List <TrainStation> {
                stationA, stationB, stationC, stationD, stationE
            });

            trainMap.AddRoute("CDC".ToCharArray());
            trainMap.AddRoute("CEBC".ToCharArray());
            trainMap.AddRoute("ABCDC".ToCharArray());
            trainMap.AddRoute("ADCDC".ToCharArray());
            trainMap.AddRoute("ADEBC".ToCharArray());
            trainMap.AddRoute("CEBCDC".ToCharArray());
            trainMap.AddRoute("CDCEBC".ToCharArray());
            trainMap.AddRoute("CDEBC".ToCharArray());
            trainMap.AddRoute("CEBCEBC".ToCharArray());
            trainMap.AddRoute("CEBCEBCEBC".ToCharArray());

            return(trainMap);

            #endregion
        }