public void CalculateMaxFlow_BasicTest() { //arrange var g = new AdjacencyMatrixGraph(true, 11); g.AddEdge(0, 1, 2); g.AddEdge(0, 2); g.AddEdge(2, 6); g.AddEdge(1, 4); g.AddEdge(1, 3); g.AddEdge(6, 9); g.AddEdge(4, 8); g.AddEdge(3, 7); g.AddEdge(2, 5); g.AddEdge(5, 8); g.AddEdge(8, 10); g.AddEdge(9, 10); g.AddEdge(8, 10); g.AddEdge(7, 10); //act var test = new BestAllocationFinder(g); //act var res = test.CalculateMaxFlow(); //assert //prev.ShouldAllBeEquivalentTo(new int[] { -1, 0, 1, 0 }); var ge = new GraphExport(); ge.Export(res); }
static void Main(string[] args) { string path = ""; var silet = false; if (args != null) { if (args.Length > 1 && args[1] == "-s") { Console.SetOut(new StreamWriter(Stream.Null)); silet = true; } if (args.Length > 0) { path = args[0]; } } Console.WriteLine("program started"); try { var f = new FileReader(path); var epi = f.ReadFile(); var baf = new BestAllocationFinder(epi); var resGraph = baf.CalculateMaxFlow(); var res = resGraph.GraphToAllocationResult(epi.ProjectCount, epi.SkillCount, epi.ExpertCount); var waste = res.GetResourceWasted(baf.ExpertProjectInformation.ExpertCount); f.SaveResult(res, waste); Console.WriteLine("zmarnowane: " + waste); Console.WriteLine("Dopasowanie:"); Console.WriteLine(res); } catch (FileNotFoundException) { Console.WriteLine("Plik nie jest znaleziony, upewnij sie ze jest w folderze TestCases/"); } catch { Console.WriteLine("Nienznany blad"); } Console.Write("Nacisnij klawisz: "); if (!silet) { Console.ReadKey(); } }
public void FullTest_Simple() { var f = new FileReader("Simple.txt"); var epi = f.ReadFile(); var baf = new BestAllocationFinder(epi); var resGraph = baf.CalculateMaxFlow(); var res = resGraph.GraphToAllocationResult(epi.ProjectCount, epi.SkillCount, epi.ExpertCount); res.ExpertToProjects.Should().HaveCount(2); res.ExpertToProjects.FirstOrDefault(x => x.ExpertId == 0 && x.ProjectId == 0 && x.SkillId == 1).Should().NotBeNull(); res.ExpertToProjects.FirstOrDefault(x => x.ExpertId == 1 && x.ProjectId == 1 && x.SkillId == 0).Should().NotBeNull(); }
public void FullTest_duzy2() { var f = new FileReader("duzy2.txt"); var epi = f.ReadFile(); var baf = new BestAllocationFinder(epi); var resGraph = baf.CalculateMaxFlow(); //TODO //ten sposob wywolan jest na pewno do refactoru var res = resGraph.GraphToAllocationResult(epi.ProjectCount, epi.SkillCount, epi.ExpertCount); res.ExpertToProjects.Should().HaveCount(1); res.ExpertToProjects.FirstOrDefault(x => x.ExpertId == 0 && x.ProjectId == 9 && x.SkillId == 9).Should().NotBeNull(); }
public void CalculateMaxFlow_SimpleTest() { //arrange var g = new AdjacencyMatrixGraph(true, 5); g.AddEdge(0, 1); g.AddEdge(1, 2); g.AddEdge(2, 3); g.AddEdge(3, 4); //act var test = new BestAllocationFinder(g); //act var res = test.CalculateMaxFlow(); //assert //prev.ShouldAllBeEquivalentTo(new int[] { -1, 0, 1, 0 }); var ge = new GraphExport(); ge.Export(res); }
public void PerformanceTest_FullGraphBetweenLayers(int count) { //setup var path = "Full" + count + ".txt"; GenerateFullFile(count, path); var sw = new Stopwatch(); sw.Start(); //arrange var f = new FileReader(path); var epi = f.ReadFile(); var baf = new BestAllocationFinder(epi); var resGraph = baf.CalculateMaxFlow(); var time = sw.ElapsedMilliseconds.ToString(); _output.WriteLine(time); sw.Stop(); var res = resGraph.GraphToAllocationResult(epi.ProjectCount, epi.SkillCount, epi.ExpertCount); res.ExpertToProjects.Should().HaveCount(count); for (int i = 0; i < count; i++) { res.ExpertToProjects.FirstOrDefault(x => x.ExpertId == i && x.ProjectId == i && x.SkillId == i).Should().NotBeNull(); } //save File.AppendAllText("../../../ExampleResults/Full.csv", count + "," + time + Environment.NewLine); }