public override void OnInspectorGUI() { GraphGenerator graphGenerator = (GraphGenerator)target; if (DrawDefaultInspector() && graphGenerator.autoUpdate) { graphGenerator.GenerateGraph(); } if (GUILayout.Button("Generate")) { graphGenerator.GenerateGraph(); } }
public void GenerateGraph_withProject_returnsGraph() { var project = CreateProject("sample"); var generator = new GraphGenerator(CreateProjectList(project), CreateNodeGenerator(), CreateEdgeGenerator()); Assert.That(generator.GenerateGraph(), Is.Not.Null); }
public void GenerateGraphGeneratesBackTriangleGraphStructure2() { var target = GraphGenerator.GenerateGraph(3, 4, 2); GraphTestHelper.AssertConsistsOfSequences(target, new[] { new[] { 0, 2 }, new[] { 0, 3 }, new[] { 0, 4 }, new[] { 0, 5 }, new[] { 1, 2 }, new[] { 1, 3 }, new[] { 1, 4 }, new[] { 1, 5 }, new[] { 2, 6 }, new[] { 2, 7 }, new[] { 2, 8 }, new[] { 2, 9 }, new[] { 3, 6 }, new[] { 3, 7 }, new[] { 3, 8 }, new[] { 3, 9 }, new[] { 4, 10 }, new[] { 4, 11 }, new[] { 4, 12 }, new[] { 4, 13 }, new[] { 5, 10 }, new[] { 5, 11 }, new[] { 5, 12 }, new[] { 5, 13 }, }); }
public void CanBuildGraph() { var generateGraph = GraphGenerator.GenerateGraph(4, 6, 2, 3); Assert.AreEqual(4, generateGraph.Vertexes.Count); Assert.AreEqual(6, generateGraph.Edges.Count); }
public void GenerateGraphGeneratesTriangleGraphStructure1_BackSequencesTest() { var target = GraphGenerator.GenerateGraph(3, 2, 4); GraphTestHelper.AssertConsistsOfBackSequences(target, new[] { new[] { 8, 0 }, new[] { 8, 1 }, new[] { 8, 2 }, new[] { 8, 3 }, new[] { 9, 0 }, new[] { 9, 1 }, new[] { 9, 2 }, new[] { 9, 3 }, new[] { 10, 4 }, new[] { 10, 5 }, new[] { 10, 6 }, new[] { 10, 7 }, new[] { 11, 4 }, new[] { 11, 5 }, new[] { 11, 6 }, new[] { 11, 7 }, new[] { 12, 8 }, new[] { 12, 9 }, new[] { 12, 10 }, new[] { 12, 11 }, new[] { 13, 8 }, new[] { 13, 9 }, new[] { 13, 10 }, new[] { 13, 11 }, }); }
public void GenerateGraphGeneratesTriangleGraphStructure2() { var target = GraphGenerator.GenerateGraph(3, 2, 4); GraphTestHelper.AssertConsistsOfSequences(target, new[] { new[] { 0, 8 }, new[] { 1, 8 }, new[] { 2, 8 }, new[] { 3, 8 }, new[] { 0, 9 }, new[] { 1, 9 }, new[] { 2, 9 }, new[] { 3, 9 }, new[] { 4, 10 }, new[] { 5, 10 }, new[] { 6, 10 }, new[] { 7, 10 }, new[] { 4, 11 }, new[] { 5, 11 }, new[] { 6, 11 }, new[] { 7, 11 }, new[] { 8, 12 }, new[] { 9, 12 }, new[] { 10, 12 }, new[] { 11, 12 }, new[] { 8, 13 }, new[] { 9, 13 }, new[] { 10, 13 }, new[] { 11, 13 }, }); }
public void GenerateGraph() { var gb = new GraphGenerator(); var myGrapth = gb.GenerateGraph(testGraph); Assert.IsNotNull(myGrapth); Assert.IsTrue(myGrapth.Count > 0); }
public void CanBuildBigGraph() { const int vertexes = 100; var generateGraph = GraphGenerator.GenerateGraph(vertexes, vertexes * (vertexes - 1) / 2, 1, 1); Assert.AreEqual(vertexes, generateGraph.Vertexes.Count); Assert.AreEqual(vertexes * (vertexes - 1) / 2, generateGraph.Edges.Count); }
public void CanBuildTree() { var tree = GraphGenerator.GenerateTree(10); GraphGenerator.GenerateGraph(10, 15, 2, 3); Assert.AreEqual(10, tree.Vertexes.Count); Assert.AreEqual(9, tree.Edges.Count); }
protected override void OnContinue() { DataDownloader.DownloadFile(Session.settingsPath); CovidData data = CovidData.LoadJson(); GraphGenerator.GenerateGraph(1200, 1200, data.getNewCasesForDays(14)); EmailSender.sendMail(); timer.Change(3600000, Timeout.Infinite); }
public Stream GenerateGraph(int numberOfNodes) { var graphGenerator = new GraphGenerator(numberOfNodes, 100); var graph = graphGenerator.GenerateGraph(); var jsonGraph = JsonSerializer.Serialize(graph); var byteArray = Encoding.ASCII.GetBytes(jsonGraph); var stream = new MemoryStream(byteArray); return(stream); }
public void GenerateGraphGeneratesCorrectNumberOfNodesAndTheirDescendantsAndPrecedents( int expectedNodeCount, int levels, int descendants, int precedents) { var target = GraphGenerator.GenerateGraph(levels, descendants, precedents); Assert.AreEqual(expectedNodeCount, target.CountNodes, "Graph expected to have {0} nodes but has {1}", expectedNodeCount, target.CountNodes); this.AssertEveryNodeHasNDescendants(target, descendants); this.AssertEveryNodeHasNPrecedents(target, precedents); }
public void MaxSum() { const int expectedSum = 16; var gb = new GraphGenerator(); var fistNode = gb.GenerateGraph(testGraph).FirstOrDefault(); var calculatedSum = fistNode.GetMaxSum(); Assert.AreEqual(expectedSum, calculatedSum); }
public void GenerateGraph_withSimpleProject_returnsGraph() { var project = CreateProject( "sample", CreateTarget("build", "clean compile"), CreateTarget("clean"), CreateTarget("compile")); var generator = new GraphGenerator(CreateProjectList(project), CreateNodeGenerator(), CreateEdgeGenerator()); Assert.That(generator.GenerateGraph(), Is.Not.Null); }
public void GenerateGraph_withSimpleProject_returnsSingleSubGraph() { var project = CreateProject( "sample", CreateTarget("build", "clean compile"), CreateTarget("clean"), CreateTarget("compile")); var generator = new GraphGenerator(CreateProjectList(project), CreateNodeGenerator(), CreateEdgeGenerator()); var graph = generator.GenerateGraph(); Assert.That(graph.SubGraphs, Has.Count.EqualTo(1)); }
public void GenerateGraphGeneratesSquareGraphStructure() { var target = GraphGenerator.GenerateGraph(3, 2, 2); GraphTestHelper.AssertConsistsOfSequences(target, new[] { new[] { 0, 2 }, new[] { 0, 3 }, new[] { 1, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 2, 5 }, new[] { 3, 4 }, new[] { 3, 5 }, }); }
static void Main(string[] args) { // Totally not a debug path here, don't mind me var namesJson = File.ReadAllText(@"../../../Resources/Names.json"); // This is like super overkill but it's ok. List <string> randomNames = JsonConvert.DeserializeObject <List <string> >(namesJson); var sampleDomain = new SampleDomain(); var generator = new GraphGenerator <string, string>(sampleDomain.nodeValues, sampleDomain.edgeValues); int numberOfNodes = 50; int numberOfEdges = 80; bool directed = true; generator.GenerateGraph(randomNames, numberOfNodes, numberOfEdges, directed); }
public void GenerateGraphGeneratesVerticalGraphStructure() { var target = GraphGenerator.GenerateGraph(10, 1, 1); GraphTestHelper.AssertConsistsOfSequences(target, new[] { new[] { 0, 1 }, new[] { 1, 2 }, new[] { 2, 3 }, new[] { 3, 4 }, new[] { 4, 5 }, new[] { 5, 6 }, new[] { 6, 7 }, new[] { 7, 8 }, new[] { 8, 9 }, }); }
public ViewModel() { //FieldViewModel lengthField; //FieldViewModel chunkTypeField; //ClassViewModel payloadField; //ClassViewModel chunkField; //FieldViewModel crcField; //Root = new ClassViewModel("Png", new [] //{ // new FieldViewModel("FileHeader", "byte[]"), // new CollectionViewModel("Chunks", "List<PngChunkContainer>", new [] // { // new ClassViewModel("PngChunkContainer", new [] // { // lengthField = new FieldViewModel("Length", "int"), // payloadField = new ClassViewModel("Payload", "PngChunkPayload", new [] // { // chunkTypeField = new FieldViewModel("ChunkType", "string"), // chunkField = new ClassViewModel("Chunk", "PngChunk", Enumerable.Empty<FieldViewModel>(), new [] // { // new ClassViewModel("PngImageDataChunk", new [] // { // new FieldViewModel("Data", "byte[]"), // }), // new ClassViewModel("PngImageHeaderChunk", new [] // { // new FieldViewModel("Data", "byte[]"), // }), // }) // }), // crcField = new FieldViewModel("Crc", "uint") // }), // }) //}); //lengthField.Bindings.Add(new BindingViewModel(lengthField, chunkField)); //chunkTypeField.Bindings.Add(new BindingViewModel(chunkTypeField, chunkField)); //crcField.Bindings.Add(new BindingViewModel(crcField, payloadField)); var generator = new GraphGenerator(); var graph = generator.GenerateGraph(typeof(Png)); var viewModelGenerator = new ViewModelGenerator(); Root = viewModelGenerator.Generate(graph) as ClassViewModel; }
public void IntegrationTest() { var graph = GraphGenerator.GenerateGraph(10000, 500000, 1, 400); var stopwatch = new Stopwatch(); stopwatch.Start(); var boruvka = SpanningTree.Boruvka(graph); stopwatch.Stop(); Debug.WriteLine(stopwatch.ElapsedTicks); stopwatch.Restart(); var kruskal = SpanningTree.Kruskal(graph); stopwatch.Stop(); Debug.WriteLine(stopwatch.ElapsedTicks); Assert.AreEqual(boruvka.Weight, kruskal.Weight); }
public void BestPath() { List <int> expectedPath = new List <int> { 1, 8, 5, 2 }; var gb = new GraphGenerator(); var firstNode = gb.GenerateGraph(testGraph).FirstOrDefault(); //we must calculate sum before we get path firstNode.GetMaxSum(); var calculatedPath = firstNode.GetBestPath(); for (int i = 0; i < expectedPath.Count; i++) { Assert.AreEqual(expectedPath[i], calculatedPath[i]); } }
public void GenerateGraphGeneratesTriangleGraphStructure1() { var target = GraphGenerator.GenerateGraph(3, 3, 1); GraphTestHelper.AssertConsistsOfSequences(target, new[] { new[] { 0, 1 }, new[] { 0, 2 }, new[] { 0, 3 }, new[] { 1, 4 }, new[] { 1, 5 }, new[] { 1, 6 }, new[] { 2, 7 }, new[] { 2, 8 }, new[] { 2, 9 }, new[] { 3, 10 }, new[] { 3, 11 }, new[] { 3, 12 }, }); }
public void GenerateGraph_withSimpleProject_returnsGraph() { var project = CreateProject( "sample", CreateTarget("build", "clean compile"), CreateTarget("clean"), CreateTarget("compile")); var generator = new GraphGenerator(CreateProjectList(project), CreateNodeGenerator(), CreateEdgeGenerator()); Assert.That(generator.GenerateGraph(), Is.Not.Null); }
public void Generate() { graph = GraphGenerator.GenerateGraph(); }
public void GenerateGraph_withProject_returnsGraph() { var project = CreateProject("sample"); var generator = new GraphGenerator(CreateProjectList(project), CreateNodeGenerator(), CreateEdgeGenerator()); Assert.That(generator.GenerateGraph(), Is.Not.Null); }
private static void Main() { Console.WriteLine("\nTask 3.1 Edges~=1/10*Vertexes^2"); for (var i = 1; i < 1e4 + 1; i += 100) { var stopWatch = new Stopwatch(); var graph = GraphGenerator.GenerateGraph(i, i * (i - 1) / 10, 1, (int)1e6); stopWatch.Restart(); var boruvkaSpanningTree = SpanningTree.Boruvka(graph); stopWatch.Stop(); var burovkaTime = stopWatch.ElapsedTicks; stopWatch.Restart(); var kruskalSpanningTree = SpanningTree.Kruskal(graph); stopWatch.Stop(); var kruskalTime = stopWatch.ElapsedTicks; var kruskalWeight = kruskalSpanningTree.Weight; var burovkaWeight = boruvkaSpanningTree.Weight; var testResult = new TestResult { Edges = graph.Edges.Count, Vertexes = graph.Vertexes.Count, WeightsMatched = burovkaWeight == kruskalWeight ? "Passed" : "Failed", BurovkaTime = burovkaTime, KruskalTime = kruskalTime }; Console.WriteLine(testResult); } Console.WriteLine("\nTask 3.1 Full Graph"); for (var i = 1; i < 1e4 + 1; i += 100) { var stopWatch = new Stopwatch(); var graph = GraphGenerator.GenerateFullGraph(i, 1, (int)1e6); stopWatch.Restart(); var boruvkaSpanningTree = SpanningTree.Boruvka(graph); stopWatch.Stop(); var burovkaTime = stopWatch.ElapsedTicks; stopWatch.Restart(); var kruskalSpanningTree = SpanningTree.Kruskal(graph); stopWatch.Stop(); var kruskalTime = stopWatch.ElapsedTicks; var kruskalWeight = kruskalSpanningTree.Weight; var burovkaWeight = boruvkaSpanningTree.Weight; var testResult = new TestResult { Edges = graph.Edges.Count, Vertexes = graph.Vertexes.Count, WeightsMatched = burovkaWeight == kruskalWeight ? "Passed" : "Failed", BurovkaTime = burovkaTime, KruskalTime = kruskalTime }; Console.WriteLine(testResult); } Console.WriteLine("\nTask 3.2 Edges=100*Vertexes"); for (var i = 201; i < 1e4 + 1; i += 100) { var stopWatch = new Stopwatch(); var graph = GraphGenerator.GenerateGraph(i, 100 * i, 1, (int)1e6); stopWatch.Restart(); var boruvkaSpanningTree = SpanningTree.Boruvka(graph); stopWatch.Stop(); var burovkaTime = stopWatch.ElapsedTicks; stopWatch.Restart(); var kruskalSpanningTree = SpanningTree.Kruskal(graph); stopWatch.Stop(); var kruskalTime = stopWatch.ElapsedTicks; var kruskalWeight = kruskalSpanningTree.Weight; var burovkaWeight = boruvkaSpanningTree.Weight; var testResult = new TestResult { Edges = graph.Edges.Count, Vertexes = graph.Vertexes.Count, WeightsMatched = burovkaWeight == kruskalWeight ? "Passed" : "Failed", BurovkaTime = burovkaTime, KruskalTime = kruskalTime }; Console.WriteLine(testResult); } Console.WriteLine("\nTask 3.2 Edges=1000*Vertexes"); for (var i = 3001; i < 1e4 + 1; i += 100) { var stopWatch = new Stopwatch(); var graph = GraphGenerator.GenerateGraph(i, 1000 * i, 1, (int)1e6); stopWatch.Restart(); var boruvkaSpanningTree = SpanningTree.Boruvka(graph); stopWatch.Stop(); var burovkaTime = stopWatch.ElapsedTicks; stopWatch.Restart(); var kruskalSpanningTree = SpanningTree.Kruskal(graph); stopWatch.Stop(); var kruskalTime = stopWatch.ElapsedTicks; var kruskalWeight = kruskalSpanningTree.Weight; var burovkaWeight = boruvkaSpanningTree.Weight; var testResult = new TestResult { Edges = graph.Edges.Count, Vertexes = graph.Vertexes.Count, WeightsMatched = burovkaWeight == kruskalWeight ? "Passed" : "Failed", BurovkaTime = burovkaTime, KruskalTime = kruskalTime }; Console.WriteLine(testResult); } Console.WriteLine("\nTask 3.3"); for (var i = (int)1e5; i < 1e7; i += (int)1e5) { var stopWatch = new Stopwatch(); var graph = GraphGenerator.GenerateGraph((int)(1e4) + 1, i, 1, (int)1e6); stopWatch.Restart(); var boruvkaSpanningTree = SpanningTree.Boruvka(graph); stopWatch.Stop(); var burovkaTime = stopWatch.ElapsedTicks; stopWatch.Restart(); var kruskalSpanningTree = SpanningTree.Kruskal(graph); stopWatch.Stop(); var kruskalTime = stopWatch.ElapsedTicks; var kruskalWeight = kruskalSpanningTree.Weight; var burovkaWeight = boruvkaSpanningTree.Weight; var testResult = new TestResult { Edges = graph.Edges.Count, Vertexes = graph.Vertexes.Count, WeightsMatched = burovkaWeight == kruskalWeight ? "Passed" : "Failed", BurovkaTime = burovkaTime, KruskalTime = kruskalTime }; Console.WriteLine(testResult); } Console.WriteLine("\nTask 3.4 Full Graph"); for (var i = 1; i <= 200; i++) { var stopWatch = new Stopwatch(); var graph = GraphGenerator.GenerateFullGraph((int)(1e4) + 1, 1, i); stopWatch.Restart(); var boruvkaSpanningTree = SpanningTree.Boruvka(graph); stopWatch.Stop(); var burovkaTime = stopWatch.ElapsedTicks; stopWatch.Restart(); var kruskalSpanningTree = SpanningTree.Kruskal(graph); stopWatch.Stop(); var kruskalTime = stopWatch.ElapsedTicks; var kruskalWeight = kruskalSpanningTree.Weight; var burovkaWeight = boruvkaSpanningTree.Weight; var testResult = new TestResult { Edges = graph.Edges.Count, Vertexes = graph.Vertexes.Count, WeightsMatched = burovkaWeight == kruskalWeight ? "Passed" : "Failed", BurovkaTime = burovkaTime, KruskalTime = kruskalTime }; Console.WriteLine(testResult); } Console.WriteLine("\nTask 3.4 Edges = 1000 * Vertexes"); for (var i = 1; i <= 200; i++) { var stopWatch = new Stopwatch(); var graph = GraphGenerator.GenerateGraph((int)(1e4) + 1, (int)1e7, 1, i); stopWatch.Restart(); var boruvkaSpanningTree = SpanningTree.Boruvka(graph); stopWatch.Stop(); var burovkaTime = stopWatch.ElapsedTicks; stopWatch.Restart(); var kruskalSpanningTree = SpanningTree.Kruskal(graph); stopWatch.Stop(); var kruskalTime = stopWatch.ElapsedTicks; var kruskalWeight = kruskalSpanningTree.Weight; var burovkaWeight = boruvkaSpanningTree.Weight; var testResult = new TestResult { Edges = graph.Edges.Count, Vertexes = graph.Vertexes.Count, WeightsMatched = burovkaWeight == kruskalWeight ? "Passed" : "Failed", BurovkaTime = burovkaTime, KruskalTime = kruskalTime }; Console.WriteLine(testResult); } }
public void GenerateGraph_withSimpleProject_returnsSingleSubGraph() { var project = CreateProject( "sample", CreateTarget("build", "clean compile"), CreateTarget("clean"), CreateTarget("compile")); var generator = new GraphGenerator(CreateProjectList(project), CreateNodeGenerator(), CreateEdgeGenerator()); var graph = generator.GenerateGraph(); Assert.That(graph.SubGraphs, Has.Count.EqualTo(1)); }