public static void Run(Random rnd, int size, double edgeProb, int numOfNodes, string resultDir) { var globalVectorType = GlobalVectorType.Sum; var epsilon = new ThresholdEpsilon(10); var amountOfIterations = 500; var initMatrix = GenerateMatrix(size, edgeProb, rnd); var vectorLength = initMatrix.Count; var fileName = $"SpectralGap_VectorLength_{vectorLength}_Nodes_{numOfNodes}_Iterations_{amountOfIterations}.csv"; var resultPath = Path.Combine(resultDir, fileName); using (var resultCsvFile = File.CreateText(resultPath)) { resultCsvFile.AutoFlush = true; resultCsvFile.WriteLine(AccumaltedResult.Header(numOfNodes)); var multiRunner = MultiRunner.InitAll(SplitTo(initMatrix, size, numOfNodes, rnd), numOfNodes, vectorLength, globalVectorType, epsilon, SpectralGapFunction.MonitoredFunction); multiRunner.OnlySchemes(new MonitoringScheme.Distance(2), new MonitoringScheme.Value(), new MonitoringScheme.Vector(), new MonitoringScheme.Naive(), new MonitoringScheme.Oracle()); var changes = GenerateChanges(initMatrix, numOfNodes, rnd).Take(amountOfIterations); multiRunner.RunAll(changes, rnd, false) .FinishAfter(multiRunner.Runners.Count, r => double.IsNegativeInfinity(r.LowerBound)) .Select(r => r.AsCsvString()) .ForEach((Action <string>)resultCsvFile.WriteLine); } Process.Start(resultPath); }
public static void RunOnData(string graphPath, string resultDir) { var globalVectorType = GlobalVectorType.Sum; var epsilon = new ThresholdEpsilon(10); var numOfNodes = 2; var fileName = $"SpectralGap__YoutubeGraph__Nodes_{numOfNodes}.csv"; var resultPath = Path.Combine(resultDir, fileName); var operations = GraphParsing.ReadGraph(graphPath); var initGraph = (GraphOperation.InitGraph)operations.First(); var numOfVerices = initGraph.NumOfVertices; using (var resultCsvFile = File.CreateText(resultPath)) { } Process.Start(resultPath); }