public void CreateEmptyTest() { var graph = DirectedGraph.CreateEmpty(5); Assert.AreEqual(graph.VerticesCount, 5); Assert.AreEqual(graph.EdgesCount, 0); }
//конец добавлени-удаления /// <summary> Задание загружено </summary> /// <param name="e"></param> protected override void OnTaskLoadingComlete(VariantDownloadedEventArgs e) { // Мы вызваны из другого потока. Поэтому работаем с UI-элементами через Dispatcher. //Dispatcher.BeginInvoke(() => { GivenGraph = VariantSerializer.Deserialize(e.Data)[0]; }); //var number = e.Number; -- м.б. тоже где-то показать надо //var version = e.Version; GivenGraph = DirectedGraph.CreateEmpty(0); MatrixGraph = (DirectedGraph)VariantSerializer.Deserialize(e.Data)[0]; Matrix = new ObservableCollection <MatrixRowViewModel <string> >(); for (var i = 0; i < MatrixGraph.VerticesCount; ++i) { var row = new ObservableCollection <string> { i.ToString() }; for (var j = 0; j < MatrixGraph.VerticesCount; ++j) { var testEdge = new DirectedEdge(MatrixGraph.Vertices[i], MatrixGraph.Vertices[j]); row.Add(MatrixGraph.Edges.Any(testEdge.Equals) //row.Add((MatrixGraph[MatrixGraph.Vertices[i],MatrixGraph.Vertices[j]] != null) ? "1" : "0"); } row.CollectionChanged += RowChanged; Matrix.Add(new MatrixRowViewModel <string>(row)); } }
public static byte[] GetSerializedVariant() { var graph1 = DirectedGraph.CreateEmpty(7); graph1.AddEdge(new DirectedEdge(graph1.Vertices[0], graph1.Vertices[5])); graph1.AddEdge(new DirectedEdge(graph1.Vertices[1], graph1.Vertices[0])); graph1.AddEdge(new DirectedEdge(graph1.Vertices[1], graph1.Vertices[5])); graph1.AddEdge(new DirectedEdge(graph1.Vertices[2], graph1.Vertices[1])); graph1.AddEdge(new DirectedEdge(graph1.Vertices[2], graph1.Vertices[5])); graph1.AddEdge(new DirectedEdge(graph1.Vertices[3], graph1.Vertices[4])); graph1.AddEdge(new DirectedEdge(graph1.Vertices[4], graph1.Vertices[2])); graph1.AddEdge(new DirectedEdge(graph1.Vertices[4], graph1.Vertices[3])); graph1.AddEdge(new DirectedEdge(graph1.Vertices[5], graph1.Vertices[6])); graph1.AddEdge(new DirectedEdge(graph1.Vertices[6], graph1.Vertices[4])); var graph2 = DirectedGraph.CreateEmpty(7); graph2.AddEdge(new DirectedEdge(graph2.Vertices[0], graph2.Vertices[5])); graph2.AddEdge(new DirectedEdge(graph2.Vertices[1], graph2.Vertices[0])); graph2.AddEdge(new DirectedEdge(graph2.Vertices[1], graph2.Vertices[5])); graph2.AddEdge(new DirectedEdge(graph2.Vertices[2], graph2.Vertices[1])); graph2.AddEdge(new DirectedEdge(graph2.Vertices[2], graph2.Vertices[5])); graph2.AddEdge(new DirectedEdge(graph2.Vertices[3], graph2.Vertices[4])); graph2.AddEdge(new DirectedEdge(graph2.Vertices[4], graph2.Vertices[2])); graph2.AddEdge(new DirectedEdge(graph2.Vertices[4], graph2.Vertices[3])); graph2.AddEdge(new DirectedEdge(graph2.Vertices[5], graph2.Vertices[6])); graph2.AddEdge(new DirectedEdge(graph2.Vertices[6], graph2.Vertices[4])); return(VariantSerializer.Serialize(new IGraph[] { graph1, graph2 })); }
/// <summary>asdsf </summary> public static byte[] GetSerializedGraph() { var graph = DirectedGraph.CreateEmpty(7); graph.AddEdge(new DirectedEdge(graph.Vertices[0], graph.Vertices[5])); graph.AddEdge(new DirectedEdge(graph.Vertices[1], graph.Vertices[0])); graph.AddEdge(new DirectedEdge(graph.Vertices[1], graph.Vertices[5])); graph.AddEdge(new DirectedEdge(graph.Vertices[2], graph.Vertices[1])); graph.AddEdge(new DirectedEdge(graph.Vertices[2], graph.Vertices[5])); graph.AddEdge(new DirectedEdge(graph.Vertices[3], graph.Vertices[4])); graph.AddEdge(new DirectedEdge(graph.Vertices[4], graph.Vertices[2])); graph.AddEdge(new DirectedEdge(graph.Vertices[4], graph.Vertices[3])); graph.AddEdge(new DirectedEdge(graph.Vertices[5], graph.Vertices[6])); graph.AddEdge(new DirectedEdge(graph.Vertices[6], graph.Vertices[4])); return(GraphSerializer.Serialize(graph)); }
/// <summary> Сгенерировать отладочный вариант </summary> protected override TaskVariantDto GetDebugVariant() { var debugGraph = DirectedGraph.CreateEmpty(7); debugGraph.AddEdge(new DirectedEdge(debugGraph.Vertices[0], debugGraph.Vertices[5])); debugGraph.AddEdge(new DirectedEdge(debugGraph.Vertices[1], debugGraph.Vertices[0])); debugGraph.AddEdge(new DirectedEdge(debugGraph.Vertices[1], debugGraph.Vertices[5])); debugGraph.AddEdge(new DirectedEdge(debugGraph.Vertices[2], debugGraph.Vertices[1])); debugGraph.AddEdge(new DirectedEdge(debugGraph.Vertices[2], debugGraph.Vertices[5])); debugGraph.AddEdge(new DirectedEdge(debugGraph.Vertices[3], debugGraph.Vertices[4])); debugGraph.AddEdge(new DirectedEdge(debugGraph.Vertices[4], debugGraph.Vertices[2])); debugGraph.AddEdge(new DirectedEdge(debugGraph.Vertices[4], debugGraph.Vertices[3])); debugGraph.AddEdge(new DirectedEdge(debugGraph.Vertices[5], debugGraph.Vertices[6])); debugGraph.AddEdge(new DirectedEdge(debugGraph.Vertices[6], debugGraph.Vertices[4])); var serializedGraph = VariantSerializer.Serialize(new IGraph[] { debugGraph }); return(new TaskVariantDto { Data = serializedGraph, GeneratorVersion = "1.0", Number = "Debug", Version = 1 }); }