public void TestListIO() { createAppdataFolder(); var file = Path.Combine(AppDataDirectory, "tests\\test.list"); Random rand = new Random(); for (int i = 0; i < 25; ++i) { GraphMatrix matrix = GraphGenerator.generatorGnp(2 + rand.Next(i), 0.5); GraphList list = Converter.ConvertToList(matrix); GraphLoad.SaveList(list, file); GraphList second = GraphLoad.LoadList(file); Assert.IsTrue(list.Equals(second)); } }
private void LoadGraph(object sender, RoutedEventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.DefaultExt = ".matrix"; dlg.Filter = "Matrix|*.matrix|List|*.list|Incidency|*.inc"; dlg.InitialDirectory = SaveLoadWindowHelper.LoadCurrentDialogDirectory(); bool?result = dlg.ShowDialog(); if (result == true) { if (dlg.FileName.ToLower().EndsWith("matrix")) { Graph.Set(GraphLoad.LoadMatrix(dlg.FileName)); } else if (dlg.FileName.ToLower().EndsWith("list")) { Graph.Set( Converter.ConvertToMatrix(GraphLoad.LoadList(dlg.FileName)) ); } else if (dlg.FileName.ToLower().EndsWith("inc")) { Graph.Set( Converter.ConvertToMatrix(GraphLoad.LoadMatrixInc(dlg.FileName)) ); } SaveLoadWindowHelper.SaveCurrentDialogDirectory(System.IO.Path.GetDirectoryName(dlg.FileName)); } else { SaveLoadWindowHelper.SaveCurrentDialogDirectory(dlg.InitialDirectory); } Graph.OnChange(); GraphRenderer.Displayer = new CircleDisplayer(); }