public static void zad1() { var result = new Tests().StartTest(100, 10, 10000, 10); var graph = new GraphGenerator(); graph.AddSeries("quick", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item1.Select(x => (double)x.Key).ToList(), result.Item1.Select(x => x.Value.Item1).ToList(), Color.Red); graph.AddSeries("sedge", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item2.Select(x => (double)x.Key).ToList(), result.Item2.Select(x => x.Value.Item1).ToList(), Color.Blue); graph.AddSeries("yaro", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item3.Select(x => (double)x.Key).ToList(), result.Item3.Select(x => x.Value.Item1).ToList(), Color.Green); graph.SaveGraph("oczekiwana check"); graph = new GraphGenerator(); graph.AddSeries("quick", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item1.Select(x => (double)x.Key).ToList(), result.Item1.Select(x => x.Value.Item2).ToList(), Color.Red); graph.AddSeries("sedge", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item2.Select(x => (double)x.Key).ToList(), result.Item2.Select(x => x.Value.Item2).ToList(), Color.Blue); graph.AddSeries("yaro", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item3.Select(x => (double)x.Key).ToList(), result.Item3.Select(x => x.Value.Item2).ToList(), Color.Green); graph.SaveGraph("wariacja check"); graph = new GraphGenerator(); graph.AddSeries("quick", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item1.Select(x => (double)x.Key).ToList(), result.Item1.Select(x => x.Value.Item3).ToList(), Color.Red); graph.AddSeries("sedge", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item2.Select(x => (double)x.Key).ToList(), result.Item2.Select(x => x.Value.Item3).ToList(), Color.Blue); graph.AddSeries("yaro", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item3.Select(x => (double)x.Key).ToList(), result.Item3.Select(x => x.Value.Item3).ToList(), Color.Green); graph.SaveGraph("oczekiwana swap"); graph = new GraphGenerator(); graph.AddSeries("quick", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item1.Select(x => (double)x.Key).ToList(), result.Item1.Select(x => x.Value.Item4).ToList(), Color.Red); graph.AddSeries("sedge", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item2.Select(x => (double)x.Key).ToList(), result.Item2.Select(x => x.Value.Item4).ToList(), Color.Blue); graph.AddSeries("yaro", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, result.Item3.Select(x => (double)x.Key).ToList(), result.Item3.Select(x => x.Value.Item4).ToList(), Color.Green); graph.SaveGraph("wariacja swap"); }
/** * Unit tests the {@code HopcroftKarp} data type. * Takes three command-line arguments {@code V1}, {@code V2}, and {@code E}; * creates a random bipartite graph with {@code V1} + {@code V2} vertices * and {@code E} edges; computes a maximum matching and minimum vertex cover; * and prints the results. * * @param args the command-line arguments */ public static void main(String[] args) { int V1 = Integer.parseInt(args[0]); int V2 = Integer.parseInt(args[1]); int E = Integer.parseInt(args[2]); Graph G = GraphGenerator.bipartite(V1, V2, E); if (G.V() < 1000) StdOut.println(G); HopcroftKarp matching = new HopcroftKarp(G); // print maximum matching StdOut.printf("Number of edges in max matching = %d\n", matching.size()); StdOut.printf("Number of vertices in min vertex cover = %d\n", matching.size()); StdOut.printf("Graph has a perfect matching = %b\n", matching.isPerfect()); StdOut.println(); if (G.V() >= 1000) return; StdOut.print("Max matching: "); for (int v = 0; v < G.V(); v++) { int w = matching.mate(v); if (matching.isMatched(v) && v < w) // print each edge only once StdOut.print(v + "-" + w + " "); } StdOut.println(); // print minimum vertex cover StdOut.print("Min vertex cover: "); for (int v = 0; v < G.V(); v++) if (matching.inMinVertexCover(v)) StdOut.print(v + " "); StdOut.println(); }
void Start() { if (mc != null) { DestroyImmediate(gameObject); return; } mc = this; gg = Instantiate(generatorPrefab) as GraphGenerator; currentNode = gg.Generate(); if (storedNodeIndex != -1) { currentNode = gg.GetNode(storedNodeIndex); } currentNode.SetActive(true); Camera.main.transform.position = new Vector3(currentNode.transform.position.x, currentNode.transform.position.y, -20); mship = Instantiate(mshipprefab, currentNode.transform.position, Quaternion.identity) as MapMothership; mship.SetState(MshipState.ORBIT, currentNode); }
public void Test() { var columns = new string[5] { "Algorithm", "Vertices Count", "Edges Percent", "Calls Limit", "Time" }; var separator = ","; var filePath = "./times.csv"; File.WriteAllText(filePath, string.Join(separator, columns) + Environment.NewLine); Stopwatch stopwatch; UndirectedGraph graph, result; for (int i = 3; i < 8; i++) { for (double j = 0.2d; j < 0.8d; j += 0.2d) { graph = GraphGenerator.Generate(i, j); for (int k = 1; k <= 4; k++) { stopwatch = Stopwatch.StartNew(); result = new EdgeAlgorithm(k).ColorGraph(graph); stopwatch.Stop(); File.AppendAllText(filePath, string.Join(separator, "Edge", i, j.ToString(CultureInfo.InvariantCulture), k, stopwatch.ElapsedMilliseconds) + Environment.NewLine); stopwatch = Stopwatch.StartNew(); result = new MatchingAlgorithm(k).ColorGraph(graph); stopwatch.Stop(); File.AppendAllText(filePath, string.Join(separator, "Matching", i, j.ToString(CultureInfo.InvariantCulture), k, stopwatch.ElapsedMilliseconds) + Environment.NewLine); } } } }
//Add node based on the indexing of the typeOfNode, will determine what kind of node spawn at each index. //Insert the appropriate list of integers to spawn the appropriate node types for each node. protected void GenerateInitPlanet(GraphGenerator generator, List <int> nodeTypes, int numberOfNodes, float scale) { listOfNodes = new List <PlanetNode>(); listOfLinks = new List <PlanetLink>(); GraphGenerator.GraphData graphData = generator.Generate(numberOfNodes, scale, containerForBoth.transform.position); for (int i = 0; i < graphData.nodes.Count; i++) { if (i > nodeTypes.Count - 1) { break; } GameObject obj = Instantiate(typeOfNode[nodeTypes[i]], graphData.nodes[i], graphData.nodes_rot[i], containerForNodes.transform); PlanetNode node = obj.GetComponent <PlanetNode>(); node.index = i; listOfNodes.Add(node); } for (int i = 0; i < graphData.links.Count; i += 2) { //Will definetly have no direction links because i said so. if (!graphData.isLinksDirectional) { GameObject obj = Instantiate(typeOfLink, Vector3.zero, Quaternion.identity, containerForLinks.transform); PlanetLink link = obj.GetComponent <PlanetLink>(); int index1 = graphData.links[i]; int index2 = graphData.links[i + 1]; link.nodePrev = listOfNodes[index1]; link.nodeNext = listOfNodes[index2]; link.PlaceLinkAtNodes(); listOfLinks.Add(link); } } }
private void GenerateGraphStrip_Click(object sender, EventArgs e) { GenerateDialog genDialog = new GenerateDialog(); if (genDialog.ShowDialog() == DialogResult.OK) { if (_forestGraph.VerticesCount() > 0 && !_saved) { DialogResult result = MessageBox.Show(Resources.DataAlreadyExists, Resources.DataAlreadyExistsTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result != DialogResult.Yes) { return; } } GraphGenerator.Init(_forestGraph); GraphGenerator.Generate((genDialog.JunctionsCount, genDialog.RestAreasCount, genDialog.StopsCount), genDialog.MinVertexEdge, genDialog.MaxVertexEdge); _dijkstra.Invalidate(); _rectangle = new RectangleF(0, 0, 0, 0); _graphPath.Clear(); _saved = true; graphCanvas.Invalidate(); BuildRangeTree(); } }
public static async Task Main() { var options = new AzureDevOpsClientOptions(); var workItemIds = new HashSet <int>(); #if DEBUG if (TryReadSettings(out var settings)) { options.Organization = settings.GetValueOrDefault("Organization", () => string.Empty); options.PersonalAccessToken = settings.GetValueOrDefault("PersonalAccessToken", () => string.Empty); options.Project = settings.GetValueOrDefault("Project", () => string.Empty); workItemIds = settings.GetValueOrDefault("WorkItemIds", () => string.Empty) .Split(new[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries) .Select(int.Parse) .ToHashSet(); } #endif var includeWorkItemTypes = new HashSet <WorkItemType> { WorkItemType.Epic, WorkItemType.Feature, WorkItemType.PBI }; var client = new AzureDevOpsClient(options); var crawler = new DirectLinksCrawler(client); var data = await crawler.GetData(workItemIds, includeWorkItemTypes, includeFinishedWorkItems : false); var graph = new GraphGenerator().GenerateGraph(data, workItemIds, "LR"); // http://magjac.com/graphviz-visual-editor/ can be used to test the graph System.Console.WriteLine(graph); }
public void GraphGenerator_Create_Triomino_Graph_has_to_work() { HyperGraph triominoGraph = GraphGenerator.CreateTriominoGraph(); Assert.AreEqual(56, triominoGraph.Edges.Where(e => e.IsThreeSidedEdge()).Count()); Assert.AreEqual(21, triominoGraph.Edges.Where(e => e.IsTwoSidedEdge()).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 async Task BuildingFlowGraph_ShouldBuild() { EndpointConvention.Map <EFoo>(new Uri("queue:input-queue")); var harness = new InMemoryTestHarness() { TestTimeout = TimeSpan.FromSeconds(1) }; harness.Consumer(() => new AFooConsumer()); harness.Consumer(() => new BFooConsumer()); harness.Consumer(() => new CFooConsumer()); harness.Consumer(() => new DFooConsumer()); harness.Consumer(() => new EFooConsumer()); await harness.Start(); await harness.Bus.Publish <AFoo>(new { CorrelationId = Guid.NewGuid() }); await harness.Bus.Publish <BFoo>(new { CorrelationId = Guid.NewGuid() }); var graph = await GraphGenerator.Generate(harness); var converstationGraphs = string.Join(Environment.NewLine, graph.Select(StringGraphRenderer.Render)); await harness.Stop(); this.Assent(converstationGraphs); }
//[Ignore] public void HyperGraph_GetAllCycles_has_to_work() { string path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName, "TestFiles", "tEdgeGraph.txt"); HyperGraph hyperGraph = GraphGenerator.LoadHyperGraphFromFile(path); List <List <Tuple <HyperEdge, Vertex> > > cycles = hyperGraph.GetAllSimpleCycles(); }
static void Main(string[] args) { GraphGenerator graphGenerator = new GraphGenerator(); IGraph graph = graphGenerator.Generator(); String[] metadataCollection = graph.GetRequiredValue(ReservedMetadataKeys.AllVertexMetadataKeys, typeof(String[])) as String[]; List <string> vertexExampleValues = new List <string>(); foreach (var metadata in metadataCollection) { IVertex vertex = graph.Vertices.FirstOrDefault(); if (vertex.GetValue(metadata) != null) { vertexExampleValues.Add(vertex.GetValue(metadata).ToString()); } } var ShowTheExamples = vertexExampleValues; IVertex discoveredVertex = BreadthFirstSearch(graph, "Last Name", "Pecoraro"); if (discoveredVertex != null) { string firstName = discoveredVertex.GetValue("First Name").ToString(); string lastName = discoveredVertex.GetValue("Last Name").ToString(); } }
//[Ignore] public void LoadTaskGraph() { string path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName, "TestFiles", "GRID.txt"); Graph <string> graph = GraphGenerator.LoadFromFile(path); // Der Startknoten Vertex <string> start = new Vertex <string>("1"); // die kürzesten Distanzen berechnen graph = graph.Dijkstra(graph.GetVertex(new Vertex <string>("1"))); // Den Pfad zusammenstellen Stack <Vertex <string> > dijkstraPath = new Stack <Vertex <string> >(); Vertex <string> actual = graph.GetVertex(new Vertex <string>("10000")); while (actual != start) { dijkstraPath.Push(actual); actual = actual.DijkstraAncestor; } dijkstraPath.Push(start); // Die Knoten auf dem Pfad in eine neue Datei schreiben. File.AppendAllLines(@"C:\Users\Moritz\Dropbox\Studium\Fulda\4_WS1819\GraphenNetzwerke\Klausur\GRID_solution.txt", dijkstraPath.Select(v => v.Value)); }
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 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 Testing(int count, int step, int testCount) { var result = Enumerable.Range(1, count).Select(x => GetResult(x * step, testCount)).ToList(); var numbers = result.Select(x => x.n).ToList(); var graph = new GraphGenerator(); graph.AddSeries("constPoint", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.ExpectedValue.ConstPointNumber).ToList(), Color.Red); graph.AddSeries("Cycles", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.ExpectedValue.CyclesNumber).ToList(), Color.Blue); graph.AddSeries("Records", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.ExpectedValue.RecordNumber).ToList(), Color.Green); graph.SaveGraph("ExpectedValue " + DateTime.Now); graph = new GraphGenerator(); graph.AddSeries("constPoint", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Variance.ConstPointNumber).ToList(), Color.Red); graph.AddSeries("Cycles", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Variance.CyclesNumber).ToList(), Color.Blue); graph.AddSeries("Records", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Variance.RecordNumber).ToList(), Color.Green); graph.SaveGraph("Variance " + DateTime.Now); graph = new GraphGenerator(); graph.AddSeries("constPoint", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Kurtosis.ConstPointNumber).ToList(), Color.Red); graph.AddSeries("Cycles", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Kurtosis.CyclesNumber).ToList(), Color.Blue); graph.AddSeries("Records", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, numbers, result.Select(x => x.Kurtosis.RecordNumber).ToList(), Color.Green); graph.SaveGraph("Kurtosis " + DateTime.Now); }
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 GenerateGraph() { var dotText = new List <string>() { "digraph D {", "Start -> Middle1", "Middle1 -> Start", "Start -> End [label=\"2\"]", "Middle2->End [label=\"Test\"]", "Middle1 -> Middle2 [label=\"2\"]", "}", }; var graph = GraphGenerator.FromDotText(dotText); Assert.AreEqual(4, graph.Nodes.Count()); Assert.AreEqual(5, graph.Edges.Count()); var text = graph.ToDotText(); Assert.IsTrue(text.Contains("Start -> Middle1")); Assert.IsTrue(text.Contains("Middle1 -> Start")); Assert.IsTrue(text.Contains("Start -> End")); Assert.IsTrue(text.Contains("Middle2 -> End")); Assert.IsTrue(text.Contains("Middle1 -> Middle2")); var image = graph.ToImage(GraphVizPath); Assert.IsNotNull(image); }
public Form2(string path) { InitializeComponent(); graphCreator = new GraphGenerator(); graphCreator.GenerateGraphInfo(path); Form2_load(); }
public void Constructor_withProject_setsProperty() { var project = CreateProject("sample"); var generator = new GraphGenerator(CreateProjectList(project), CreateNodeGenerator(), CreateEdgeGenerator()); Assert.That(generator.Projects, Has.Count.EqualTo(1)); }
public void GetPossibleChildNodes_must_work() { // Node from where childNodes should be calculated TwoBuckets tb1 = new TwoBuckets(3, 5, 2, 3); // Get the list with possible child nodes. IEnumerable <TwoBuckets> neighborVertices = GraphGenerator.GetNeighborVertices(tb1); // Expected NeighborNodes TwoBuckets tb2 = new TwoBuckets(3, 5, 3, 2); // Fill1From2 TwoBuckets tb3 = new TwoBuckets(3, 5, 0, 5); // Fill2From1 TwoBuckets tb4 = new TwoBuckets(3, 5, 0, 3); // Empty1 TwoBuckets tb5 = new TwoBuckets(3, 5, 2, 0); // Empty2 TwoBuckets tb6 = new TwoBuckets(3, 5, 2, 5); // Fill1 TwoBuckets tb7 = new TwoBuckets(3, 5, 3, 3); // Fill2 // Check result Assert.AreEqual(6, neighborVertices.Count()); Assert.IsTrue(neighborVertices.Contains(tb2)); Assert.IsTrue(neighborVertices.Contains(tb3)); Assert.IsTrue(neighborVertices.Contains(tb4)); Assert.IsTrue(neighborVertices.Contains(tb5)); Assert.IsTrue(neighborVertices.Contains(tb6)); Assert.IsTrue(neighborVertices.Contains(tb7)); // Test special case TwoBuckets tb8 = new TwoBuckets(3, 5); neighborVertices = GraphGenerator.GetNeighborVertices(tb8); // Check Result Assert.AreEqual(2, neighborVertices.Count()); Assert.IsTrue(neighborVertices.Contains(new TwoBuckets(3, 5, 0, 5))); Assert.IsTrue(neighborVertices.Contains(new TwoBuckets(3, 5, 3, 0))); }
public void Test() { var G1 = GraphGenerator.dag(); var dc = new DirectedCycles(G1); console.WriteLine("dag has cycles: " + dc.HasCycle); }
public void BucketGraph_must_work() { Graph <TwoBuckets> bucketGraph = GraphGenerator.BucketGraph(3, 5); string expectedAdjacencyMatrix = " ||0-0|3-0|0-5|3-5|0-3|3-2|3-3|0-2|1-5|2-0|1-0|2-5|0-1|3-4|3-1|0-4\r\n" + "======================================================================\r\n" + "0-0|| 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" + "3-0|| 1 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" + "0-5|| 1 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" + "3-5|| 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" + "0-3|| 1 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" + "3-2|| 0 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" + "3-3|| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" + "0-2|| 1 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" + "1-5|| 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 \r\n" + "2-0|| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 \r\n" + "1-0|| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 \r\n" + "2-5|| 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 \r\n" + "0-1|| 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 \r\n" + "3-4|| 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 \r\n" + "3-1|| 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 \r\n" + "0-4|| 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 \r\n"; string adjacencyMatrix = bucketGraph.GetAdjacencyMatrix(); Assert.AreEqual(expectedAdjacencyMatrix, adjacencyMatrix); }
// Funkcja tworząca graf. private void CreateGraph() { inputArray = GraphGenerator.NewGraphArray(Convert.ToInt32(textBoxCreateGraphSize.Text), Convert.ToDouble(listBoxSource[listBoxCreateGraphDensity.SelectedIndex]), 0, 0, checkBoxCreateGraphDirected.Checked); graph = new Graph(inputArray, checkBoxCreateGraphDirected.Checked); textBoxCreateGraphSize.BackColor = Color.MediumAquamarine; }
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 }, }); }
void Test(int t, int n, ISchedule schedule, string scheduleName) { var graph = new GraphGenerator(1000, 600); var Listk = new List <int> { 10, 9, 8, 7, 6, 5 }; Listk = Listk.Select(x => n / x).Distinct().ToList(); var fifol = new List <double>(); var fwfl = new List <double>(); var lrul = new List <double>(); var lful = new List <double>(); var randl = new List <double>(); var rmal = new List <double>(); Listk.ForEach(k => { int fifoc, fwfc, lruc, lfuc, randc, rmac; fifoc = fwfc = lruc = lfuc = randc = rmac = 0; for (int j = 0; j < 100; j++) { var fifo = new FIFOCache(k); var fwf = new FWFCachecs(k); var lru = new LRUCache(k); var lfu = new LFUCache(k); var rand = new RandCache(k); var rma = new RMACache(k); for (int i = 0; i < t; i++) { var x = schedule.GetNextNumber(); fifoc += fifo.GetValue(x); fwfc += fwf.GetValue(x); lruc += lru.GetValue(x); lfuc += lfu.GetValue(x); randc += rand.GetValue(x); rmac += rma.GetValue(x); } } fifol.Add(fifoc / 100); fwfl.Add(fwfc / 100); lrul.Add(lruc / 100); lful.Add(lfuc / 100); randl.Add(randc / 100); rmal.Add(rmac / 100); }); var kk = Listk.Select(x => (double)x).ToList(); graph.AddSeries($"{scheduleName}_FIFO_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, fifol, Color.Red); graph.AddSeries($"{scheduleName}_FWF_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, fwfl, Color.Blue); graph.AddSeries($"{scheduleName}_LRU_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, lrul, Color.Black); graph.AddSeries($"{scheduleName}_LFU_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, lful, Color.Yellow); graph.AddSeries($"{scheduleName}_RAND_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, randl, Color.Green); graph.AddSeries($"{scheduleName}_RMA_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, rmal, Color.MediumPurple); graph.SaveGraph($"{scheduleName}_{n}_3"); }
public void GetFullGraph_CountTest_ShouldReturn_45() { int verticesCount = 10; var generator = new GraphGenerator(); var g = generator.GetFullGraph(verticesCount); Assert.AreEqual(ExpectedEdgesCountInFullGraph(verticesCount), g.EdgeCount); }
public void GenerateGraph() { var gb = new GraphGenerator(); var myGrapth = gb.GenerateGraph(testGraph); Assert.IsNotNull(myGrapth); Assert.IsTrue(myGrapth.Count > 0); }
public void Test() { DiGraph dag = GraphGenerator.dag(); var dfo = new DepthFirstPostOrder(dag); console.WriteLine(dfo.PostOrderToString()); }
/// <summary> /// Lädt einen Graphen aus der gegebenen Datei. /// </summary> /// <param name="fileName"></param> /// <returns>Der Graph aus der Datei.</returns> private static Graph <string> LoadGraph(string fileName, bool isDirected = false) { // Den Graphen aus der Datei laden. string filePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), fileName); Graph <string> graph = GraphGenerator.LoadFromFile(filePath, isDirected); return(graph); }
public void GenerateGraph_should_include_all_packages() { var repo = new LocalPackageRepository(@"..\..\..\packages"); var g = new GraphGenerator(repo); using (var s = File.OpenWrite("nuget.dgml")) { g.WriteGraph(s); s.Flush(); } }
public void GenerateGraph_with_assemblies_should_include_all_packages() { var repo = new LocalPackageRepository(@"..\..\..\packages"); var g = new GraphGenerator(repo) { IncludeAssemblyReferences = true }; using (var s = File.OpenWrite("nuget.dgml")) { g.WriteGraph(s); s.Flush(); } }
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); }
// Use this for initialization void Start() { Random.seed = (int)Time.time; this.pathfinder = GameObject.Find("Core").GetComponent<GraphGenerator>(); if(pathfinder == null){ Debug.LogError("Problem: Failed to locate GraphGenerator script in scene. Make sure it is attached to a GameObject called 'Pathfinder'."); } you = this.gameObject.transform; controller = (CharacterController)you.gameObject.GetComponent(typeof(CharacterController)); target = GameObject.FindGameObjectWithTag("Cultist"); waypoints = GameObject.FindGameObjectsWithTag("waypoint"); chaseTimer = 0; }
public void GenerateGraphImage_withSimpleProject_returnsImage() { var project = CreateProject( "sample", CreateTarget("build", "clean compile"), CreateTarget("clean"), CreateTarget("compile")); var generator = new GraphGenerator(CreateProjectList(project), CreateNodeGenerator(), CreateEdgeGenerator()); var graph = generator.GenerateGraphImage(); Assert.That(graph, Is.Not.Null); graph.Save("GenerateGraphImage.png"); }
void Start() { if (mc != null) { DestroyImmediate (gameObject); return; } mc = this; gg = Instantiate (generatorPrefab) as GraphGenerator; currentNode = gg.Generate (); if (storedNodeIndex != -1) { currentNode = gg.GetNode(storedNodeIndex); } currentNode.SetActive (true); Camera.main.transform.position = new Vector3 (currentNode.transform.position.x, currentNode.transform.position.y, -20); mship = Instantiate(mshipprefab, currentNode.transform.position, Quaternion.identity) as MapMothership; mship.SetState(MshipState.ORBIT, currentNode); }
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)); }
/// <summary> /// Render a graph for the passed NAntProjects /// </summary> /// <param name="projects">Sequence of projects to render</param> /// <returns>Generated image</returns> public Image Render(IEnumerable<NAntProject> projects) { var nodeGenerator = new NodeGenerator { IncludeDescriptions = mIncludeDescriptions, LabelFont = mLabelFont, LabelFontSize = mLabelFontSize }; var edgeGenerator = new EdgeGenerator(); var generator = new GraphGenerator(projects, nodeGenerator, edgeGenerator); mImage = generator.GenerateGraphImage(); mDotScript = generator.DotText; return Image; }