public static void CreateFile() { CityNodeCollection collection = new CityNodeCollection(); collection.Add(new CityNode('A', 'B', 2)); //0 collection.Add(new CityNode('A', 'E', 2)); //0 collection.Add(new CityNode('A', 'W', 1)); //0 collection.Add(new CityNode('B', 'D', 5)); collection.Add(new CityNode('B', 'W', 4)); collection.Add(new CityNode('B', 'C', 2)); collection.Add(new CityNode('B', 'F', 3)); collection.Add(new CityNode('C', 'F', 7)); collection.Add(new CityNode('C', 'V', 9)); collection.Add(new CityNode('D', 'E', 1)); collection.Add(new CityNode('D', 'J', 7)); collection.Add(new CityNode('E', 'K', 3)); collection.Add(new CityNode('F', 'L', 2)); collection.Add(new CityNode('F', 'M', 7)); collection.Add(new CityNode('F', 'R', 3)); collection.Add(new CityNode('F', 'Y', 1)); collection.Add(new CityNode('G', 'K', 8)); collection.Add(new CityNode('G', 'J', 5)); collection.Add(new CityNode('G', 'H', 2)); collection.Add(new CityNode('H', 'I', 4)); collection.Add(new CityNode('H', 'P', 1)); collection.Add(new CityNode('I', 'K', 5)); collection.Add(new CityNode('J', 'O', 3)); collection.Add(new CityNode('J', 'L', 2)); collection.Add(new CityNode('L', 'N', 4)); collection.Add(new CityNode('N', 'O', 1)); collection.Add(new CityNode('O', 'P', 1)); collection.Add(new CityNode('M', 'N', 5)); collection.Add(new CityNode('M', 'Z', 3)); collection.Add(new CityNode('M', 'X', 1)); collection.Add(new CityNode('Z', 'N', 6)); collection.Add(new CityNode('X', 'Z', 2)); collection.Add(new CityNode('Y', 'X', 5)); collection.Add(new CityNode('R', 'S', 4)); collection.Add(new CityNode('S', 'V', 2)); //Serilize it Data.XML.SerializeToFile(collection, "city 1.xml"); CityNodeCollection collection2 = new CityNodeCollection(); collection2.Add(new CityNode('A', 'B', 2)); //1 collection2.Add(new CityNode('A', 'C', 3)); //2 collection2.Add(new CityNode('A', 'D', 4)); //3 collection2.Add(new CityNode('B', 'C', 2)); //4 collection2.Add(new CityNode('B', 'E', 1)); //5 collection2.Add(new CityNode('C', 'E', 7)); //6 collection2.Add(new CityNode('D', 'E', 8)); //7 collection2.Add(new CityNode('D', 'C', 3)); //8 Data.XML.SerializeToFile(collection2, "1.xml"); }
public MainViewModel() { //************************************************************** // Initialize GUI-Variables //************************************************************** FromDropdownlist = new ObservableCollection<char>(); DestDropdownlist = new ObservableCollection<char>(); OutputText = new ObservableCollection<string>(); //************************************************************** // Graph and loading the file //************************************************************** ShortestPath.CreateFile(); //Creates an xml file of the textfile //collection = Data.XML.DeserializeFromFile<CityNodeCollection>("city 1.xml"); //Collection of all the paths collection = Data.XML.DeserializeFromFile<CityNodeCollection>("1.xml"); //Collection of all the paths HashSet<char> uniques = new HashSet<char>(); //Unique nodes DennisAlphabet = new Dictionary<char, int>(); //Get all unique chars from city collection foreach (var item in collection) { uniques.Add(item.From); uniques.Add(item.Dest); } int i = 0; foreach (var unique in uniques) { //Adds to the drop down list FromDropdownlist.Add(unique); DestDropdownlist.Add(unique); } List<char> characters = new List<char>(FromDropdownlist); characters.Sort(); foreach (var item in characters) { DennisAlphabet.Add(item, i); i++; } //**************************************************************** // Events //**************************************************************** StartSimulation = new RelayCommand<object>(StartSimulation_Event); ResetSimulation = new RelayCommand<object>(ResetSimulation_Event); StopSimulation = new RelayCommand<object>(StopSimulation_Event); stopwatch = new Stopwatch(); BellmanWatch = new Stopwatch(); }