public ActionResult ReadFromFile() { ViewBag.FileError = ""; if (HttpContext.Request.Files.AllKeys.Any()) { var httpPostedFile = HttpContext.Request.Files[0]; if (httpPostedFile != null) { var index = httpPostedFile.FileName.LastIndexOf(@"\"); var shotName = httpPostedFile.FileName.Substring(index == -1 ? 0 : index); var fileSavePath = HttpContext.Server.MapPath("~/UploadedFiles") + shotName; try { httpPostedFile.SaveAs(fileSavePath); IGraphInitializer graphInitializer = new GraphFromFile(fileSavePath); GraphProblemDb.CurrentProblem.Graph = graphInitializer.Initialize(); } catch (Exception e) { ViewBag.FileError = "Формат файла не вірний."; return(RedirectToAction("Error", "Home")); } } } return(RedirectToAction("OutputEditGraph", GraphProblemDb.CurrentProblem.Graph)); }
public static void Main(string[] args) { var filepath = System.IO.Path.GetFullPath(@"D:\Studing\ТРПЗ\Курсова робота\CW_Nelya_Vika\CW_Nelya_Vika\CW_Nelya_Vika_Algorithms\Data\graph1.txt"); GirvanNewman gn = new GirvanNewman(); //KernighanLin kl = new KernighanLin(); //Graph g = GraphProblemDb.GetGraph(1); //Console.WriteLine(g); //IGraphInitializer graphInitializer = new GraphGenerator(ProblemClassification.Xs); IGraphInitializer graphInitializer = new GraphFromFile(filepath); Graph g1 = graphInitializer.Initialize(); g1.CommunityCount = 5; GraphList resuslt = gn.FindCommunityStructure(g1); //Problem problem1 = new Problem(); //problem1.Graph = g1; //problem1.Algorithm = Algorithm.GirvanNewman; //problem1.GraphList = resuslt; ////GraphProblemDb.AddProblem(problem1); //GraphList result_kl = kl.FindCommunityStructure(g1); //Problem problem2 = new Problem(); //problem2.Graph = g1; //problem2.Algorithm = Algorithm.KernighanLin; //problem2.GraphList = result_kl; //GraphProblemDb.AddProblem(problem2); //GraphProblemDb.CloseConnection(); Console.WriteLine(gn.Log); Console.ReadLine(); }