private void InsertBreakBetween(string stationA, string stationB)
        {
            int aId = sd.GetKey(stationA);
            int bId = sd.GetKey(stationB);

            if (aId == -1)
            {
                throw new ArgumentException(stationA + " is misspelt");
            }

            if (bId == -1)
            {
                throw new ArgumentException(stationB + " is misspelt");
            }

            var children = MetroNetwork.GenChildrenFromStationId(aId);

            for (int i = 0; i < children.Count(); i++)
            {
                if (children[i].StationId == bId)
                {
                    MetroNetwork.InsertBreakBetween(aId, children[i]);
                    break;
                }
            }
        }
        private BaseDictionary[] InitialiseMetroNetwork()
        {
            StationDictionary stationDiction = new StationDictionary(APIHandler.GetStationList());
            LineDictionary    lineDiction    = new LineDictionary(APIHandler.GetLineList(), APIHandler.GetLineColors());

            MetroNetwork.Initialise(stationDiction, lineDiction);

            BaseDictionary[] dictionaries = new BaseDictionary[] { stationDiction, lineDiction };
            return(dictionaries);
        }
        public string CutEdge(int index)
        {
            Node child = Children[index];

            MetroNetwork.InsertBreakBetween(ParentId, child);

            string rec = LineDiction.GetValue(child.LineIndex) + ": " + StationDiction.GetValue(ParentId) + " - " + StationDiction.GetValue(child.StationId);

            return(rec);
        }
        public void InsertBreakTest()
        {
            int parentId = sd.GetKey("lancaster gate");
            var children = MetroNetwork.GenChildrenFromStationId(parentId);

            Assert.IsTrue(CheckContains(children, "queensway"));
            InsertBreakBetween("lancaster gate", "queensway");
            children = MetroNetwork.GenChildrenFromStationId(parentId);
            Assert.IsFalse(CheckContains(children, "queensway"));
        }
        public void GenChildrenFromIdTest()
        {
            var        children    = MetroNetwork.GenChildrenFromStationId(sd.GetKey("hammersmith"));
            List <int> childrenIds = new List <int>();

            childrenIds.Add(sd.GetKey("Goldhawk Road"));
            childrenIds.Add(sd.GetKey("Barons Court"));
            childrenIds.Add(sd.GetKey("Ravenscourt Park"));
            childrenIds.Add(sd.GetKey("Turnham Green"));

            foreach (var child in children)
            {
                Assert.IsTrue(childrenIds.Contains(child.StationId));
            }
        }
        // constructor

        public Backend()
        {
            // instantiating variables
            List <string> tempList = new List <string>();

            Children = new List <Node>();

            // api requests
            tempList    = APIHandler.GetLineList();                                 // makes request for list of lines
            LineDiction = new LineDictionary(tempList, APIHandler.GetLineColors()); // sets up line dictionary

            tempList       = APIHandler.GetStationList();                           // makes request for station list
            StationDiction = new StationDictionary(tempList);                       // sets up station dictionary

            MetroNetwork.Initialise(StationDiction, LineDiction);                   // sets up network structure
        }
        // editing methods

        public List <string> GetNeighbourNames(int parentId)
        {
            Children.Clear();
            this.ParentId = parentId;
            List <string> neighbours = new List <string>();

            Children = MetroNetwork.GenChildrenFromStationId(this.ParentId);
            string val;

            foreach (var child in Children)
            {
                val = LineDiction.GetValue(child.LineIndex) + ": " + StationDiction.GetValue(child.StationId);
                neighbours.Add(val);
            }

            return(neighbours);
        }