public void DataVertex_Constructor_Test() 
        {
            var vertex = new DataVertex(1, "title");

            Assert.AreEqual(vertex.Id, 1);
            Assert.AreEqual(vertex.Title, "title");
        }
Пример #2
0
 public static DataEdge GenerateEdge(DataVertex source, DataVertex target, int weight = 0)
 {
     return new DataEdge(source, target, weight) 
     {
         Text = string.Empty
     };
 }
Пример #3
0
        public void CreateEdgeOperation_Do_Test()
        {
            var graph = new Model.GraphArea();

            var source = new DataVertex(100) { };
            var sourceVC = new VertexControl(source);
            graph.Graph.AddVertex(source);
            graph.AddVertex(source, sourceVC);

            var target = new DataVertex(101) { };
            var targetVC = new VertexControl(target);
            graph.Graph.AddVertex(target);
            graph.AddVertex(target, targetVC);

            bool called = false;
            EdgeControl ec = null;
            var ceo = new CreateEdgeOperation(graph, source, target, (e) =>
            {
                called = true;
                ec = e;
            },
            (e) =>
            {

            });

            ceo.Do();

            Assert.IsTrue(called);
            Assert.IsNotNull(ec);
            Assert.AreEqual<VertexControl>(ec.Source, sourceVC, "source are not equal");
            Assert.AreEqual<VertexControl>(ec.Target, targetVC, "target are not equal");
        }
        public void DataVertex_Default_Constructor_Test()
        {
            var vertex = new DataVertex();

            Assert.AreEqual(vertex.Id, -1);
            Assert.AreEqual(vertex.Title, "-1");
        }
Пример #5
0
 public EdgeOperation(GraphArea graph, DataVertex source, DataVertex target, Action<EdgeControl> callback = null, Action<EdgeControl> undoCallback = null)
 {
     _graph = graph;
     _callback = callback;
     _undoCallback = undoCallback;
     _source = source;
     _target = target;
 }
 private void MakeVertex()
 {
     vlist.Clear();
     for (var i = 0; i < 10; i++)
     {
         var v = new DataVertex(i, "DataVertex" + i);
         vlist.Add(v);
     }
 }
        public VertexPositionChangeOperation(GraphArea graph, VertexControl vc, double offsetX, double offsetY, DataVertex data = null, Action<DataVertex, VertexControl> callback = null, Action<DataVertex> undoCallback = null)
            : base(graph, data, callback, undoCallback)
        {
            _vc = vc;
            _offsetX = offsetX;
            _offsetY = offsetY;

            Status = Orc.GraphExplorer.Status.Done;
        }
 public DeleteVertexOperation(GraphArea graph, DataVertex data = null, Action<DataVertex, VertexControl> callback = null, Action<DataVertex> undoCallback = null)
     : base(graph, data, callback, undoCallback)
 {
     if (graph.VertexList.ContainsKey(_vertex))
         _vCtrl = graph.VertexList[_vertex];
     else
     {
         //throw new ArgumentNullException("Vertex Control");
     }
 }
        public CreateVertexOperation(GraphArea graph, DataVertex data = null, double x = double.MinValue, double y = double.MinValue, Action<DataVertex, VertexControl> callback = null, Action<DataVertex> undoCallback = null)
            : base(graph, data, callback, undoCallback)
        {
            _vCtrl = new VertexControl(_vertex);

            if (x != double.MinValue)
                _x = x;

            if (y != double.MinValue)
                _y = y;
        }
Пример #10
0
        public static void AddEdge(BidirectionalGraph<DataVertex, DataEdge> graph, DataVertex source, DataVertex target, int? sourcePoint = null, int? targetPoint = null, int weight = 0)
        {
            var edge = new DataEdge(source, target, weight)
            {
                Text = string.Empty,
                SourceConnectionPointId = sourcePoint,
                TargetConnectionPointId = targetPoint,
                ToolTipText = "Label "+ source.ID
            };

            graph.AddEdge(edge);
        }
Пример #11
0
        public void Do_CreateVertex_Operation_Test()
        {
            var graphVM = new GraphExplorerViewmodel();

            Assert.IsNotNull(graphVM.Operations);
            Assert.IsNotNull(graphVM.OperationsRedo);

            Assert.IsFalse(graphVM.HasChange);
            Assert.IsFalse(graphVM.HasRedoable);
            Assert.IsFalse(graphVM.HasUndoable);

            bool createSourceCalled     = false;
            bool undoCreateSourceCalled = false;
            var  graph  = new Model.GraphArea();
            var  source = new DataVertex(100)
            {
                Title = "Test"
            };
            VertexControl sourceVC = null;

            var cvoSource = new CreateVertexOperation(graph, source, callback: (sv, svc) =>
            {
                createSourceCalled = true;
                sourceVC           = svc;
            },
                                                      undoCallback: (v) =>
            {
                undoCreateSourceCalled = true;
            });

            graphVM.Do(cvoSource);

            Assert.IsTrue(createSourceCalled);
            Assert.IsNotNull(sourceVC);
            Assert.IsTrue(graph.Graph.Vertices.Any(v => v == source));
            Assert.AreEqual(source, sourceVC.Vertex, "source are not equal");

            Assert.IsTrue(graphVM.HasChange);
            //Assert.IsTrue(graphVM.HasRedoable);
            Assert.IsTrue(graphVM.HasUndoable);

            graphVM.UndoCommand.Execute();

            Assert.IsTrue(undoCreateSourceCalled);
            Assert.IsNotNull(sourceVC);
            Assert.IsFalse(graph.Graph.Vertices.Any(v => v == source));
            Assert.IsNull(sourceVC.Vertex, "source sould be null");

            Assert.IsTrue(graphVM.HasChange);
            Assert.IsTrue(graphVM.HasRedoable);
            //Assert.IsTrue(graphVM.HasUndoable);
        }
 public EdgeConfigurationView(DataVertex dv, Dictionary <string, DataVertex> globalVertices,
                              TestFeederGenerator.Models.GraphX graph, string key, Dictionary <string, List <DataEdge> > globalEdges,
                              bool isUpdate, VertexControl vc, GraphArea area, MainWindow mn,
                              Dictionary <string, Models.CableConfiguration> globalCableConfiguration,
                              EdgeControl ec = null, DataEdge de = null, VertexControl _ecFrom = null)
 {
     InitializeComponent();
     _ec          = ec;
     data         = de;
     this._ecFrom = _ecFrom;
     initializeLocalVariablesNewEdge(dv, graph, globalVertices, key, globalEdges, isUpdate, area, vc, mn, globalCableConfiguration);
     mainWindow = App.Current.MainWindow as MainWindow;
 }
Пример #13
0
        public static void AddEdge(BidirectionalGraph <DataVertex, DataEdge> graph, DataVertex source, DataVertex target, int?sourcePoint = null, int?targetPoint = null, int weight = 0)
        {
            var edge = new DataEdge(source, target, weight)
            {
                ID   = Rand.Next(),
                Text = string.Empty,
                SourceConnectionPointId = sourcePoint,
                TargetConnectionPointId = targetPoint,
                ToolTipText             = "Label " + source.ID
            };

            graph.AddEdge(edge);
        }
        private void CreateTransformerVertex(DataVertex dv, double m = 0, double n = 0)
        {
            VertexControl vc;

            if (dvt != null)
            {
                MessageBox.Show("Transformer already created");
                return;
            }



            dvt = new DataVertexTransformer()
            {
                Text       = "First transfromer ending: " + dv.Element_id,
                Element_id = dv.Element_id
            };


            dvt.typeOfVertex = DataVertex.TypeOfVertex.TRANSFORMER_VERTEX;

            vc = new VertexControl(dvt);



            if (m == 0)
            {
                vc.SetPosition(new Point(x, y));
            }
            else
            {
                vc.SetPosition(m, n);
            }

            mainWindow.GlobalVertices.Add(dvt.Element_id, dvt);

            vc.Background = Brushes.GreenYellow;
            mainWindow.graphView.Area.AddVertexAndData(dvt, vc, true);



            Point point = CreatePointBasedOn(vc);

            if (graphState == GraphState.NORMAL)
            {
                x += 30;
                y += 30;
            }

            return;
        }
Пример #15
0
        public void GetValue(DataVertex vtx)
        {
            VertexBefore = vtx;
            VertexAfter  = vtx;
            switch (VertexBefore.TypeOfVertex)
            {
            case "AMCreate":
                DPDistribution.Visibility     = Visibility.Visible;
                cbbDistribution.SelectedIndex = (int)VertexBefore.CreateType.TypeDistribuion;
                tBxName.Text    = VertexBefore.Text;
                tBxTraffic.Text = VertexBefore.Traffic.ToString();
                Label1.Content  = "Начало:";
                tBx1.Text       = VertexBefore.CreateType.FirstTime.ToString();
                Label2.Content  = "Интервал:";
                tBx2.Text       = VertexBefore.CreateType.Interval.ToString();
                DP3.Visibility  = Visibility.Visible;
                Label3.Content  = "Длина файла:";
                tBx3.Text       = VertexBefore.CreateType.LengthOfFile.ToString();
                break;

            case "AMQueue":
                tBxName.Text    = VertexBefore.Text;
                tBxTraffic.Text = VertexBefore.Traffic.ToString();
                Label1.Content  = "Ёмкость очереди:";
                tBx1.Text       = VertexBefore.QueueType.QueueCapacity.ToString();
                Label2.Content  = "Приоритет:";
                tBx2.Text       = VertexBefore.QueueType.Priority.ToString();
                DP3.Visibility  = Visibility.Visible;
                Label3.Content  = "Тип файла:";
                tBx3.Text       = VertexBefore.QueueType.FileType.ToString();
                break;

            case "AMTerminate":
                tBxName.Text    = VertexBefore.Text;
                tBxTraffic.Text = VertexBefore.Traffic.ToString();
                Label1.Content  = "Выходной счетчик:";
                tBx1.Text       = VertexBefore.TerminateType.OutputCounter.ToString();
                Label2.Content  = "Момент остоновки:";
                tBx2.Text       = VertexBefore.TerminateType.StoppingTime.ToString();
                break;

            default:
                MessageBox.Show("Тип узлы не определен!");
                break;
            }

            //VertexBefore = vtx;
            //VertexAfter = vtx;
            //tBxName.Text = VertexBefore.Text;
            //tBxTraffic.Text = VertexBefore.Traffic.ToString();
        }
        internal void RecreateSerializedEdgeData(DataVertex source, DataVertex target, VertexControl vc, double length)
        {
            DataEdge de = new DataEdge(source, target);

            VertexControl vc1 = GetVertexControlWithDataVertex(source.Element_id);
            VertexControl vc2 = GetVertexControlWithDataVertex(target.Element_id);

            this.length = length;

            EdgeControl ec = new EdgeControl(vc1, vc2, de);


            AddEdge(de, ec, vc1);
        }
Пример #17
0
        private DataVertex AddNewVertexSafety(Frame mainFrame, EasyGraph dataGraph)
        {
            DataVertex mainVertex = _GetVertexByItsFrame(mainFrame, dataGraph);

            if (mainVertex == null)
            {
                mainVertex = new DataVertex(mainFrame.name)
                {
                    ID = mainFrame.Id
                };
                dataGraph.AddVertex(mainVertex);
            }
            return(mainVertex);
        }
        private readonly Func <TEdge, double> _edgeCost = e => 1; // constant cost

        public IEnumerable <TEdge> Find(TGraph dataGraph)

        {
            IEnumerable <DataVertex> vertices = dataGraph.Vertices;

            DataVertex root   = GetVertexBySymbol(vertices, new Start().Symbol);
            DataVertex target = GetVertexBySymbol(vertices, new Quit().Symbol);

            // compute shortest paths
            TryFunc <DataVertex, IEnumerable <TEdge> > tryGetPaths = dataGraph.ShortestPathsDijkstra(_edgeCost, root);

            tryGetPaths(target, out IEnumerable <TEdge> path);
            return(path);
        }
        private void ReplaceEdgeTarget(DataVertex dataVertexRegulator, DataVertex dataVertexRegulatorPartial,
                                       string old_value, VertexControl dataVertexRegulatorControl,
                                       VertexControl dataVertexRegulatorPartialControl, string length)
        {
            foreach (DataEdge dataEdge in mainWindow.GlobalEdges[dataVertexRegulator.Element_id])
            {
                if (dataEdge.Target.Element_id == old_value)
                {
                    //setup new data edge
                    DataEdge de = new DataEdge(dataVertexRegulator, dataVertexRegulatorPartial);
                    if (dataEdge.Source.typeOfVertex == DataVertex.TypeOfVertex.REGULATOR_VERTEX || dataEdge.Source.typeOfVertex == DataVertex.TypeOfVertex.TRANSFORMER_VERTEX)
                    {
                        de.Configuration = new CableConfiguration()
                        {
                            Name = "xfm_1"
                        };
                    }
                    de.Length = Double.Parse(length);
                    de.Text   = length;



                    //setup new edge control
                    EdgeControl edgeControl = new EdgeControl(dataVertexRegulatorControl, dataVertexRegulatorPartialControl, de);

                    setEdgesDashStyle(edgeControl, dataVertexRegulator.typeOfVertex);


                    //update area edges
                    mainWindow.graphView.Area.RemoveEdge(dataEdge);
                    mainWindow.graphView.Area.EdgesList.Remove(dataEdge);

                    if (dataVertexRegulator.typeOfVertex == DataVertex.TypeOfVertex.TRANSFORMER_VERTEX)
                    {
                        mainWindow.graphView.Area.AddEdge(de, edgeControl, false);
                    }
                    else
                    {
                        mainWindow.graphView.Area.AddEdge(de, edgeControl, true);
                    }


                    //update global edges
                    mainWindow.GlobalEdges[dataVertexRegulator.Element_id].Remove(dataEdge);
                    mainWindow.GlobalEdges[dataVertexRegulator.Element_id].Add(de);

                    break;
                }
            }
        }
Пример #20
0
        public DataVertex Search(GraphExample GE, int vert)
        {
            DataVertex rezult = null;
            var        list   = GE.Vertices.ToList();

            foreach (DataVertex p in list)
            {
                if (p.ID == vert)
                {
                    rezult = p;
                }
            }
            return(rezult);
        }
        private void CreateRegulatorVertex(DataVertex dv, double m = 0, double n = 0)
        {
            VertexControl vc;

            if (dvr != null)
            {
                MessageBox.Show("Regulator already created");
                return;
            }


            dvr = new DataVertexRegulator()
            {
                Text = dv.Text, Element_id = dv.Element_id
            };
            vc = new VertexControl(dvr);


            if (m == 0)
            {
                dvr.Text = "Synchronous machine first ending: " + dv.Element_id;
                vc.SetPosition(new Point(x, y));
            }
            else
            {
                vc.SetPosition(m, n);
            }



            dvr.typeOfVertex = DataVertex.TypeOfVertex.REGULATOR_VERTEX;


            vc.Background = Brushes.Red;

            mainWindow.GlobalVertices.Add(dvr.Element_id, dvr);
            mainWindow.graphView.Area.AddVertexAndData(dvr, vc, true);

            Point point = CreatePointBasedOn(vc);

            if (graphState == GraphState.NORMAL)
            {
                x += 30;
                y += 30;
            }


            return;
        }
        public void Do_CreateVertex_Operation_Test()
        {
            var graphVM = new GraphExplorerViewmodel();

            Assert.IsNotNull(graphVM.Operations);
            Assert.IsNotNull(graphVM.OperationsRedo);

            Assert.IsFalse(graphVM.HasChange);
            Assert.IsFalse(graphVM.HasRedoable);
            Assert.IsFalse(graphVM.HasUndoable);

            bool createSourceCalled = false;
            bool undoCreateSourceCalled = false;
            var graph = new Model.GraphArea();
            var source = new DataVertex(100) { Title = "Test" };
            VertexControl sourceVC = null;

            var cvoSource = new CreateVertexOperation(graph, source, callback:(sv, svc) =>
            {
                createSourceCalled = true;
                sourceVC = svc;
            },
            undoCallback:(v) =>
            {
                 undoCreateSourceCalled = true;
            });

            graphVM.Do(cvoSource);

            Assert.IsTrue(createSourceCalled);
            Assert.IsNotNull(sourceVC);
            Assert.IsTrue(graph.Graph.Vertices.Any(v => v == source));
            Assert.AreEqual(source, sourceVC.Vertex, "source are not equal");

            Assert.IsTrue(graphVM.HasChange);
            //Assert.IsTrue(graphVM.HasRedoable);
            Assert.IsTrue(graphVM.HasUndoable);

            graphVM.UndoCommand.Execute();

            Assert.IsTrue(undoCreateSourceCalled);
            Assert.IsNotNull(sourceVC);
            Assert.IsFalse(graph.Graph.Vertices.Any(v => v == source));
            Assert.IsNull(sourceVC.Vertex, "source sould be null");

            Assert.IsTrue(graphVM.HasChange);
            Assert.IsTrue(graphVM.HasRedoable);
            //Assert.IsTrue(graphVM.HasUndoable);
        }
Пример #23
0
        public void DeserializeEdgeData(string edge_file)
        {
            List <GraphSerializationData> gds = FileServiceProvider.DeserializeDataFromFile(edge_file);

            foreach (GraphSerializationData x in gds)
            {
                DataVertex source = (x.Data as DataEdge).Source;
                DataVertex target = (x.Data as DataEdge).Target;

                VertexControl vc = getVertexControlWithDataVertex(source.Element_id);

                (this.DataContext as GraphViewModel).RecreateSerializedEdgeData(source, target, vc, ((DataEdge)x.Data).Length);
                //AreaAddEdge(source, target.Element_id, ((DataEdge)x.Data).Length, false, vc);
            }
        }
Пример #24
0
        public void Vertex_AddPropertyOperation_Test()
        {
            var vertex = new DataVertex();

            var apo = new AddPropertyOperation(vertex);

            apo.Do();

            Assert.IsNotNull(apo.Property);
            Assert.AreEqual(vertex.Properties.Count, 1);

            apo.UnDo();

            Assert.AreEqual(vertex.Properties.Count, 0);
        }
Пример #25
0
        private VertexControl CreateVertexControl(Point position)
        {
            var data = new DataVertex("Vertex " + (graphArea.VertexList.Count + 1))
            {
                ImageId = ShowcaseHelper.Rand.Next(0, ThemedDataStorage.EditorImages.Count)
            };

            graphArea.LogicCore.Graph.AddVertex(data);
            var vc = new VertexControl(data);

            graphArea.AddVertex(data, vc);
            GraphAreaBase.SetX(vc, position.X, true);
            GraphAreaBase.SetY(vc, position.Y, true);
            return(vc);
        }
Пример #26
0
        public void PathVertexDataInterpolation()
        {
            var Points = new DataVertex <TestVertexData> [3];

            Points[0] = new DataVertex <TestVertexData>(new Vector2(0, 0), new TestVertexData(0));
            Points[1] = new DataVertex <TestVertexData>(new Vector2(0, 100), new TestVertexData(1));
            Points[2] = new DataVertex <TestVertexData>(new Vector2(100, 0), new TestVertexData(2));

            int[] Indices = new int[3];
            Indices[0] = 0; Indices[1] = 1; Indices[2] = 2;

            Path <TestVertexData> Mesh = new Path <TestVertexData>(Points, Indices);

            Assert.AreEqual(Mesh.GetVertexData(new Vector2(100f / 3f, 100 / 3f)).Value, 1f, .0005f);
        }
        private void CreateSpotLoadVertex(DataVertex dv, double m = 0, double n = 0)
        {
            SpotLoad sp = new SpotLoad();

            VertexControl vc;

            sp.Text         = "Spot load: " + dv.Element_id;
            sp.Element_id   = dv.Element_id;
            sp.typeOfVertex = DataVertex.TypeOfVertex.SPOT_LOAD_VERTEX;

            vc = new VertexControl(sp);

            mainWindow.GlobalVertices.Add(sp.Element_id, sp);

            if (mainWindow.GlobalSpotLoads.ContainsKey(sp.Element_id))
            {
                mainWindow.GlobalSpotLoads[sp.Element_id] = sp;
            }
            else
            {
                mainWindow.GlobalSpotLoads.Add(sp.Element_id, sp);
            }



            mainWindow.spotLoadTab._globalSpotLoads = mainWindow.GlobalSpotLoads;
            mainWindow.spotLoadTab.populateListView();

            if (m == 0)
            {
                vc.SetPosition(new Point(x, y));
            }
            else
            {
                vc.SetPosition(m, n);
            }
            vc.Background = Brushes.Gray;
            mainWindow.graphView.Area.AddVertexAndData(sp, vc, true);

            if (graphState == GraphState.NORMAL)
            {
                x += 30;
                y += 30;
            }


            return;
        }
        private void CreateTransformerPartialVertex(DataVertex dv, double m = 0, double n = 0)
        {
            DataVertexTransformerPartial dvtp = new DataVertexTransformerPartial()
            {
                Text       = dv.Text,
                Element_id = dv.Element_id
            };

            VertexControl vc;

            vc = new VertexControl(dvtp);



            dvtp.typeOfVertex = DataVertex.TypeOfVertex.TRANSFORMER_PARTIAL_VERTEX;



            vc = new VertexControl(dvtp);


            if (m == 0)
            {
                dvtp.Text = "Second transfromer ending: " + dvtp.Element_id;
                vc.SetPosition(new Point(x, y));
            }
            else
            {
                vc.SetPosition(m, n);
            }

            mainWindow.GlobalVertices.Add(dvtp.Element_id, dvtp);

            vc.Background = Brushes.GreenYellow;
            mainWindow.graphView.Area.AddVertexAndData(dvtp, vc, true);

            Point point = CreatePointBasedOn(vc);


            if (graphState == GraphState.NORMAL)
            {
                x += 30;
                y += 30;
            }

            this.dvtp = dvtp;
            return;
        }
Пример #29
0
        /// <summary>
        /// Создает вершину и ее визуальную часть.
        /// </summary>
        /// <param name="position">Позиция вершины.</param>
        /// <returns>объект класса VertexControl.</returns>
        private VertexControl CreateVertexControl(Point position, VertexType vertexType)
        {
            double vertexCost = 0.0;

            if (vertexType == VertexType.Unmarket)
            {
                var dlg = new AddVertexDataCostDialog(this);
                if (dlg.ShowDialog() == false)
                {
                    return(null);
                }
                vertexCost = dlg.cost;
            }

            var data = new DataVertex(vertexType, vertexCost);

            switch (vertexType)
            {
            case VertexType.GroupeVillage:
                data.Color = VertexColor.GroupeVillage;
                break;

            case VertexType.Unmarket:
                data.Color = VertexColor.Unmarked;
                break;
            }


            var control = new VertexControl(data);


            switch (data.Color)
            {
            case VertexColor.GroupeVillage:
                control.Style = App.Current.Resources["VillageGroupVertex"] as Style;
                break;

            case VertexColor.Unmarked:
                control.Style = App.Current.Resources["DefaultVertex"] as Style;
                break;
            }

            control.SetPosition(position);

            graphArea.AddVertexAndData(data, control, true);
            ClearCreateMode();
            return(control);
        }
Пример #30
0
        public void DataVertex_AddCommand_Test()
        {
            var observer = new MockObserver();

            var vertex = new DataVertex();

            vertex.Subscribe(observer);

            vertex.AddCommand.Execute();

            Assert.AreEqual(observer.Operations.Count, 1);

            vertex.AddCommand.Execute();

            Assert.AreEqual(observer.Operations.Count, 2);
        }
Пример #31
0
        public void DataVertex_AddCommand_Test()
        {
            var observer = new MockObserver();

            var vertex = new DataVertex();

            vertex.Subscribe(observer);

            vertex.AddCommand.Execute();

            Assert.AreEqual(observer.Operations.Count, 1);

            vertex.AddCommand.Execute();

            Assert.AreEqual(observer.Operations.Count, 2);
        }
 private void initializeLocalVariablesUpdateEdge(DataVertex dv, TestFeederGenerator.Models.GraphX graph, Dictionary <string, DataVertex> globalVertices, string key, Dictionary <string, List <DataEdge> > globalEdges, bool isUpdate, DataEdge de, VertexControl vc, MainWindow mn, Dictionary <string, CableConfiguration> globalCableConfiguration)
 {
     _dv                       = dv;
     _graph                    = graph;
     _globalVertices           = globalVertices;
     _key                      = key;
     _globalEdges              = globalEdges;
     idLabel.Content           = "Nodes to connect: " + dv.Text + " -> " + key;
     txtBox.Text               = de.Length.ToString();
     _isUpdate                 = isUpdate;
     _mn                       = mn;
     _vc                       = vc;
     _globalCableConfiguration = globalCableConfiguration;
     cbo.ItemsSource           = _globalCableConfiguration.Keys;
     cbo.SelectedIndex         = 0;
 }
Пример #33
0
        public void EditKeyPropertyOperation_Test()
        {
            var vertex   = new DataVertex();
            var property = new PropertyViewmodel(1, "key", "value", vertex);

            vertex.AddProperty(property);
            var ekpo = new EditKeyPropertyOperation(property, "key changed");

            ekpo.Do();

            Assert.AreEqual(property.Key, "key changed");

            ekpo.UnDo();

            Assert.AreEqual(property.Key, "key");
        }
Пример #34
0
        private GraphGeneric GenerateGraph()
        {
            Vertices = new List <DataVertex>();
            var dataGraph   = new GraphGeneric();
            var nodeCount   = InputPermutations[0].Count;
            var probability = Convert.ToDouble(txb_prob.Text, CultureInfo.InvariantCulture);

            LackingEdges = new List <int> [nodeCount];
            for (int i = 0; i < nodeCount; i++)
            {
                LackingEdges[i] = new List <int>();
                for (int j = 0; j < i; j++)
                {
                    if (R.NextDouble() >= probability)
                    {
                        LackingEdges[j].Add(i);
                    }
                }
            }

            int[][] permutationsMatrix = MakePermutationsMatrix(0);

            for (int i = 0; i < nodeCount; i++)
            {
                var dataVertex = new DataVertex(i.ToString());
                Vertices.Add(dataVertex);
                dataGraph.AddVertex(dataVertex);
            }

            for (int i = 0; i < nodeCount; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    if (permutationsMatrix[i][j] >= penalty)
                    {
                        dataGraph.AddEdge(new DataEdge(Vertices[j], Vertices[i], permutationsMatrix[i][j])
                        {
                            EdgeColor = Colors.Red
                        });
                    }
                    dataGraph.AddEdge(new DataEdge(Vertices[j], Vertices[i], permutationsMatrix[i][j]));
                }
            }

            return(dataGraph);
        }
Пример #35
0
        private void Search_The_Way_Click(object sender, RoutedEventArgs e)
        {
            Method_Minti Method   = new Method_Minti(GraphExample_Setup(), matrix);
            GraphExMinti AftMinti = Method.find_the_way();

            tbSettingText.Clear();
            tbSettingText.AppendText("Список шляхів та відстаней:");
            tbSettingText.AppendText(Environment.NewLine);
            for (int i = 1; i < numOfVertices; i++)
            {
                string     LineRezult = "";
                DataVertex tmp        = AftMinti.Vertex[i].vert;
                tbSettingText.AppendText(string.Format("H = {0} Дуга: ", AftMinti.Vertex[i].dist));

                while (!(tmp == AftMinti.Vertex[0].vert))
                {
                    foreach (DataEdgeMinti j in AftMinti.Edges)
                    {
                        if (j.Edges.Target == tmp && j.Label)
                        {
                            if (tmp.Text.Length > 1)
                            {
                                char[] str = tmp.Text.ToCharArray();
                                Array.Reverse(str);
                                LineRezult += new string(str) + "-";
                                tmp         = j.Edges.Source;
                                break;
                            }
                            else
                            {
                                LineRezult += tmp.Text + "-";
                                tmp         = j.Edges.Source;
                                break;
                            }
                        }
                    }
                }
                LineRezult += "1";
                char[] s = LineRezult.ToCharArray();
                Array.Reverse(s);

                tbSettingText.AppendText(new string(s));
                tbSettingText.AppendText(Environment.NewLine);
            }
        }
        internal void CreateComplexVertexWithPartialType(DataVertex existing_transformer_vertex,
                                                         DataVertex existing_transformer_vertex_partial, DataVertex clicked_vertex,
                                                         string length = null, CableConfiguration cableConfiguration = null)
        {
            mainWindow.GlobalVertices[existing_transformer_vertex.Element_id] = existing_transformer_vertex;
            string local_length = "0";

            foreach (VertexControl vc in Area.VertexList.Values)
            {
                DataVertex dv = (DataVertex)vc.Vertex;



                if (length != null)
                {
                    local_length = length;
                }

                if (dv.Text == clicked_vertex.Text)
                {
                    //update areas vertex
                    vc.Vertex = existing_transformer_vertex;

                    //remove old and add updated vertex
                    mainWindow.graphView.Area.VertexList.Remove(dv);
                    mainWindow.graphView.Area.VertexList.Add(existing_transformer_vertex, vc);

                    //create
                    CreateDataVertexBase(existing_transformer_vertex_partial.typeOfVertex, existing_transformer_vertex_partial.Element_id);

                    //connect new partial and existing

                    _ecFrom = GetVertexControlWithDataVertex(dv.Element_id);

                    VertexControl target = GetVertexControlWithDataVertex(existing_transformer_vertex_partial.Element_id);

                    graphState = GraphState.PARTIAL_CONNECTING;

                    ConnectEdges(target, int.Parse(local_length));

                    graphState = GraphState.NORMAL;
                    break;
                }
            }
        }
        // Summary:
        //   populate vertexes data from properties data loaded from csv file
        public static List<DataVertex> PopulateVertexes(List<PropertyData> records)
        {
            var query = from record in records
                        group record by record.ID into g
                        select new { g.Key, Properties = g.ToDictionary(d => d.Property, d => d.Value) };
            List<DataVertex> vlist = new List<DataVertex>();

            foreach (var result in query)
            {
                var vertex = new DataVertex(result.Key);

                vertex.SetProperties(result.Properties);
                //vertex.Properties = GenerateProperties(result.Properties, vertex);
                vlist.Add(vertex);
            }

            return vlist;
        }
Пример #38
0
        public RegulatorView(DataVertex dv)
        {
            InitializeComponent();

            this.dv             = dv;
            this._mn            = App.Current.MainWindow as MainWindow;
            this.globalVertices = _mn.GlobalVertices;
            this.globalEdges    = _mn.GlobalEdges;


            DataVertexRegulator dvr = (DataVertexRegulator)dv;

            if (dvr.RegulatorID != null)
            {
                populateViewIfObjectExists(dvr);
            }

            setupViewDeafultValues();
        }
        public void PrepareComplexVertexForDelete(DataVertex dv)
        {
            VertexControl vc = GetVertexControlWithDataVertex(dv.Element_id);

            Point p = CreatePointBasedOn(vc);

            DeleteVertex(dv);


            if (dv.typeOfVertex == DataVertex.TypeOfVertex.REGULATOR_VERTEX)
            {
                dvr = (DataVertexRegulator)dv;
                if (dvr.Line_Segment_To != null)
                {
                    if (mainWindow.GlobalVertices.Keys.Contains(dvr.Line_Segment_To))
                    {
                        DeleteVertex(mainWindow.GlobalVertices[dvr.Line_Segment_To]);
                        mainWindow.GlobalVertices.Remove(dvr.Line_Segment_To);
                        dvrp = null;
                    }
                }

                dvr = null;
            }
            else if (dv.typeOfVertex == DataVertex.TypeOfVertex.TRANSFORMER_VERTEX)
            {
                dvt = (DataVertexTransformer)dv;
                if (dvt.Line_to != null)
                {
                    if (mainWindow.GlobalVertices.Keys.Contains(dvt.Line_to))
                    {
                        DeleteVertex(mainWindow.GlobalVertices[dvt.Line_to]);
                        mainWindow.GlobalVertices.Remove(dvt.Line_to);
                        dvtp = null;
                    }
                }

                dvt = null;
            }

            mainWindow.enableButtonIfEdgesExists();
            mainWindow.CloseAllWindows();
        }
Пример #40
0
        public static GraphExample GenerateGraph()
        {
            //FOR DETAILED EXPLANATION please see SimpleGraph example project
            var dataGraph = new GraphExample();

            if (DSK != null)
            {
                foreach (var key in DSK.Keys)
                {
                    var dataVertex = new DataVertex(key.ToString());
                    dataGraph.AddVertex(dataVertex);
                }
            }

            var vlist = dataGraph.Vertices.ToList();

            //Then create two edges optionaly defining Text property to show who are connected

            DataEdge dataEdge;

            foreach (var p in vlist)
            {
                foreach (var k in DSK)
                {
                    if (k.Key.ToString() == p.ToString())
                    {
                        foreach (var val in k.Value)
                        {
                            foreach (var v in vlist)
                            {
                                if (v.ToString() == val.ToString())
                                {
                                    dataEdge = new DataEdge(v, p);
                                    dataGraph.AddEdge(dataEdge);
                                }
                            }
                        }
                    }
                }
            }
            return(dataGraph);
        }
        private BidirectionalGraph <DataVertex, DataEdge> GraphPcap_Setup()
        {
            //Lets make new data graph instance
            var dataGraph = new GraphPcap();

            //Now we need to create edges and vertices to fill data graph
            //This edges and vertices will represent graph structure and connections
            //Lets make some vertices
            foreach (NetworkInterface n in interafaces)
            {
                //Create new vertex with specified Text. Also we will assign custom unique ID.
                //This ID is needed for several features such as serialization and edge routing algorithms.
                //If you don't need any custom IDs and you are using automatic Area.GenerateGraph() method then you can skip ID assignment
                //because specified method automaticaly assigns missing data ids (this behavior is controlled by method param).
                var dataVertex = new DataVertex("MAC : " + n.MAC);
                //Add vertex to data graph
                dataGraph.AddVertex(dataVertex);
            }

            //Now lets make some edges that will connect our vertices
            //get the indexed list of graph vertices we have already added
            var vlist = dataGraph.Vertices.ToList();

            //Then create two edges optionaly defining Text property to show who are connected
            foreach (NetworkInterface n in interafaces)
            {
                foreach (Connection connection in n.connections)
                {
                    var dataEdge = new DataEdge(vlist[n.pos], vlist[FindNetworkInteface(FindMacByIP(connection.adress))])
                    {
                        Text = string.Format("{0} Mb", connection.stats.speed)
                    };
                    dataGraph.AddEdge(dataEdge);
                }
            }
            //var dataEdge = new DataEdge(vlist[0], vlist[1]) { Text = string.Format("{0} -> {1}", vlist[0], vlist[1]) };
            //dataGraph.AddEdge(dataEdge);
            //dataEdge = new DataEdge(vlist[2], vlist[3]) { Text = string.Format("{0} -> {1}", vlist[2], vlist[3]) };
            //dataGraph.AddEdge(dataEdge);

            return(dataGraph);
        }
Пример #42
0
        public static GraphExample FirstSimpleExample()
        {
            var graph = new GraphExample();

            // 1. add vertexes
            var v1 = new DataVertex(1);
            var v2 = new DataVertex(2);



            graph.AddVertex(v1);
            graph.AddVertex(v2);

            // 2. add edges
            var edge1 = new DataEdge(v1, v2);

            graph.AddEdge(edge1);

            return(graph);
        }
Пример #43
0
        void dg_addvertex_Click(object sender, RoutedEventArgs e)
        {
            var data = new DataVertex();

            ThemedDataStorage.FillDataVertex(data);

            dg_Area.LogicCore.Graph.AddVertex(data);
            dg_Area.AddVertex(data, new VertexControl(data));

            //we have to check if there is only one vertex and set coordinates manulay
            //because layout algorithms skip all logic if there are less than two vertices
            if (dg_Area.VertexList.Count() == 1)
            {
                dg_Area.VertexList.First().Value.SetPosition(0, 0);
                dg_Area.UpdateLayout(); //update layout to update vertex size
            }
            else
            {
                dg_Area.RelayoutGraph(true);
            }
            dg_zoomctrl.ZoomToFill();
        }
 public AddPropertyOperation(DataVertex vertex, PropertyViewmodel property = null)
     : base(vertex, property)
 {
     base.Sammary = "Add Property";
 }
 public DeleteEdgeOperation(GraphArea graph, DataVertex source, DataVertex target,DataEdge edge, Action<EdgeControl> callback = null, Action<EdgeControl> undoCallback = null)
     : base(graph, source, target, callback, undoCallback)
 {
     _Edge = edge;
     base.Sammary = "Delete Edge";
 }
 public DeletePropertyOperation(DataVertex vertex)
     : base(vertex, null)
 {
     base.Sammary = "Delete Property";
 }
Пример #47
0
        public void Delete_Vertex_With_Related_Edges_Test()
        {
            //begin setup
            var graph = new Model.GraphArea();

            var v1 = new DataVertex(100) { };
            var v2 = new DataVertex(103) { };
            var v3 = new DataVertex(105) { };
            var vc1 = new VertexControl(v1);
            var vc2 = new VertexControl(v2);
            var vc3 = new VertexControl(v3);

            var e1 = new DataEdge(v1, v2);
            var ec1 = new EdgeControl(vc1, vc2, e1);
            var e2 = new DataEdge(v1, v3);
            var ec2 = new EdgeControl(vc1, vc3, e2);

            graph.Graph.AddVertex(v1);
            graph.AddVertex(v1, vc1);
            graph.Graph.AddVertex(v2);
            graph.AddVertex(v2, vc2);
            graph.Graph.AddVertex(v3);
            graph.AddVertex(v3, vc3);

            graph.Graph.AddEdge(e1);
            graph.AddEdge(e1, ec1);
            graph.Graph.AddEdge(e2);
            graph.AddEdge(e2, ec2);
            //end setup
            bool doCalled = false;
            bool undoCalled = false;
            var dvo = new DeleteVertexOperation(graph, v1, (dv, vc) =>
            {
                doCalled = true;
            },
            (dv) =>
            {
                undoCalled = true;
            });

            dvo.Do();

            Assert.IsTrue(doCalled);
            Assert.IsFalse(graph.VertexList.Any(v => v.Key.Id == v1.Id));
            Assert.IsTrue(graph.VertexList.Any(v => v.Key.Id == v2.Id));
            Assert.IsTrue(graph.VertexList.Any(v => v.Key.Id == v3.Id));
            Assert.IsFalse(graph.EdgesList.Any(e => e.Key == e1));
            Assert.IsFalse(graph.EdgesList.Any(e => e.Key == e2));

            dvo.UnDo();

            Assert.IsTrue(undoCalled);
            Assert.IsTrue(graph.VertexList.Any(v => v.Key.Id == v1.Id));
            Assert.IsTrue(graph.VertexList.Any(v => v.Key.Id == v2.Id));
            Assert.IsTrue(graph.VertexList.Any(v => v.Key.Id == v3.Id));
            Assert.IsTrue(graph.EdgesList.Any(e => e.Key == e1));
            Assert.IsTrue(graph.EdgesList.Any(e => e.Key == e2));

            dvo.Do();

            Assert.IsTrue(doCalled);
            Assert.IsFalse(graph.VertexList.Any(v => v.Key.Id == v1.Id));
            Assert.IsTrue(graph.VertexList.Any(v => v.Key.Id == v2.Id));
            Assert.IsTrue(graph.VertexList.Any(v => v.Key.Id == v3.Id));
            Assert.IsFalse(graph.EdgesList.Any(e => e.Key == e1));
            Assert.IsFalse(graph.EdgesList.Any(e => e.Key == e2));
        }
Пример #48
0
        public void Vertex_Set_Of_DeleteAddOperatrion_Test()
        {
            var vertex = new DataVertex();

            var p1 = new Model.PropertyViewmodel(1, "p1", "p1", vertex);
            vertex.Properties.Add(p1);
            var p2 = new Model.PropertyViewmodel(2, "p2", "p2", vertex) { IsSelected = true };
            vertex.Properties.Add(p2);
            var p3 = new Model.PropertyViewmodel(3, "p3", "p3", vertex) { IsSelected = true };
            vertex.Properties.Add(p3);

            var apo = new AddPropertyOperation(vertex);
            var dpo = new DeletePropertyOperation(vertex);

            apo.Do();
            dpo.Do();

            Assert.AreEqual(vertex.Properties.Count, 2);
            Assert.AreEqual(vertex.Properties[0], p1);
            Assert.AreEqual(vertex.Properties[1], apo.Property);

            dpo.UnDo();
            apo.UnDo();

            Assert.AreEqual(vertex.Properties.Count, 3);
            Assert.AreEqual(vertex.Properties[0], p1);
            Assert.AreEqual(vertex.Properties[1], p2);
            Assert.AreEqual(vertex.Properties[2], p3);
        }
Пример #49
0
        public void VertexPositionChanged_Test()
        {
            var graph = new Model.GraphArea();

            var vertex = new DataVertex();

            var vctrol = new VertexControl(vertex);

            graph.Graph.AddVertex(vertex);

            graph.AddVertex(vertex, vctrol);

            bool called = false;
            bool undoCalled = false;

            var vpco = new VertexPositionChangeOperation(graph, vctrol, 10, 10, vertex, (v, vc) =>
            {
                called = true;
            }, (vc) =>
            {
                undoCalled = true;
            });

            vpco.Do();

            Assert.IsTrue(called);

            vpco.UnDo();

            Assert.IsTrue(undoCalled);
        }
Пример #50
0
 public static void FillDataVertex(DataVertex item)
 {
     item.Age = ShowcaseHelper.Rand.Next(18, 75);
     item.Gender = Gender[ShowcaseHelper.Rand.Next(0, 1)];
    // item.ImageId = item.Gender == ThemedDataStorage.Gender[0] ? 0 : 1;
     item.Profession = Professions[ShowcaseHelper.Rand.Next(0, Professions.Count - 1)];
     item.Name = Names[ShowcaseHelper.Rand.Next(0, Names.Count - 1)];
 }
        public void Observe_Vertex_DeletePropertyOperation_Test()
        {
            var vertex = new DataVertex();

            vertex.AddProperty(new Model.PropertyViewmodel(0, "", "", vertex) { IsSelected = true});

            var vm = new GraphExplorerViewmodel();

            vm.OnVertexLoaded(new DataVertex[] { vertex }, true);

            vertex.DeleteCommand.Execute();

            Assert.IsTrue(vm.HasUndoable);
            Assert.AreEqual(vertex.Properties.Count, 0);

            vm.UndoCommand.Execute();

            Assert.IsTrue(vm.HasRedoable);
            Assert.AreEqual(vertex.Properties.Count, 1);

            vm.RedoCommand.Execute();

            Assert.IsTrue(vm.HasUndoable);
            Assert.AreEqual(vertex.Properties.Count, 0);
        }
 public void UpdateVertex(DataVertex vertex, Action<bool, Exception> onComplete)
 {
     throw new NotImplementedException();
 }
        public void UpdateEdges_Test()
        {
            var service = new CsvGraphDataService();
            bool callSuccess = false;
            Exception er;
            List<DataEdge> list = new List<DataEdge>();
            var item1 = new DataVertex(1);
            var item2 = new DataVertex(2);
            var edge1 = new DataEdge(item1, item2);

            list.Add(edge1);

            service.UpdateEdges(list, (sucess, error) =>
            {
                er = error;
                callSuccess = sucess;
            });

            DataEdge item1FromSource = null;
            service.GetEdges((data) =>
            {
                item1FromSource = data.FirstOrDefault();

                callSuccess = true;

            }, (e) => { });

            Assert.IsTrue(callSuccess);
            Assert.IsNotNull(item1FromSource);
            Assert.AreEqual(edge1.Source.Id, item1FromSource.Source.Id);
            Assert.AreEqual(edge1.Target.Id, item1FromSource.Target.Id);
        }
Пример #54
0
        public void Vertex_AddPropertyOperation_Test()
        {
            var vertex = new DataVertex();

            var apo = new AddPropertyOperation(vertex);

            apo.Do();

            Assert.IsNotNull(apo.Property);
            Assert.AreEqual(vertex.Properties.Count, 1);

            apo.UnDo();

            Assert.AreEqual(vertex.Properties.Count, 0);
        }
        public void UpdateVertex(DataVertex vertex, Action<bool, DataVertex, Exception> onComplete)
        {
            if (vertex == null)
                return;

            try
            {
                if (vCache.ContainsKey(vertex.Id))
                {
                    vCache[vertex.Id] = vertex;
                }
                else
                {
                    vCache.Add(vertex.Id, vertex);
                }

                var list = vCache.Values.ToList();

                UpdateVertexes(list, (r, e) =>
                {
                    if (onComplete != null)
                    {
                        onComplete.Invoke(r, vertex, e);
                    }
                });
            }
            catch (Exception ex)
            {
                if (onComplete != null)
                {
                    onComplete.Invoke(true, vertex, new Exception(string.Format("error occuered during updating vertex to csv. vertex id [{0}]", vertex.ID), ex));
                }
                else
                    throw new Exception(string.Format("error occuered during updating vertex to csv. vertex id [{0}]", vertex.ID), ex);
            }
        }
        public void UpdateVertexes_Test()
        {
            var service = new CsvGraphDataService();
            bool callSuccess = false;
            Exception er;
            ObservableCollection<DataVertex> list = new ObservableCollection<DataVertex>();
            var item1 = new DataVertex(1);
            var listV = new ObservableCollection<Model.PropertyViewmodel>();
            item1.Properties = listV;

            listV.Add(new Model.PropertyViewmodel(1,"First Name", "Payton", item1));
            listV.Add(new Model.PropertyViewmodel(2,"Last Name", "Li", item1));
            listV.Add(new Model.PropertyViewmodel(3,"Age", "29", item1));

            list.Add(item1);

            service.UpdateVertexes(list, (sucess, error) =>
            {
                er = error;
                callSuccess = sucess;
            });

            DataVertex item1FromSource = null;
            service.GetVertexes((data) =>
            {
                item1FromSource = data.FirstOrDefault();

                callSuccess = true;

            }, (e) => { });

            Assert.IsTrue(callSuccess);
            Assert.IsNotNull(item1FromSource);
            Assert.AreEqual(item1.Id, item1FromSource.Id);
        }
        private void UpdateEdgeRef(int fromId, int toId, out DataVertex from, out DataVertex to)
        {
            from = null;
            to = null;

            if (!vCache.TryGetValue(fromId, out from))
            {
                from = new DataVertex(fromId);
                vCache.Add(fromId, from);
            }

            if (!vCache.TryGetValue(toId, out to))
            {
                to = new DataVertex(toId);
                vCache.Add(toId, to);
            }
        }
Пример #58
0
        public void EditValuePropertyOperation_Test()
        {
            var vertex = new DataVertex();
            var property = new PropertyViewmodel(1, "key", "value", vertex);
            vertex.AddProperty(property);
            var evpo = new EditValuePropertyOperation(property, "value changed");

            evpo.Do();

            Assert.AreEqual(property.Value, "value changed");

            evpo.UnDo();

            Assert.AreEqual(property.Value, "value");
        }
Пример #59
0
        public void VertexOperation_Undo_Redo_Test()
        {
            var graph = new Model.GraphArea();

            var source = new DataVertex(100) { };

            var target = new DataVertex(101) { };

            bool createEdgeCalled = false;
            bool undoCreateEdgeCalled = false;

            bool createSourceCalled = false;
            bool undoCreateSourceCalled = false;

            bool createTargetCalled = false;
            bool undoCreateTargetCalled = false;

            EdgeControl ec = null;
            VertexControl sourceVC = null;
            VertexControl targetVC = null;

            var ceo = new CreateEdgeOperation(graph, source, target, (e) =>
            {
                createEdgeCalled = true;
                ec = e;
            },
            (e) =>
            {
                createEdgeCalled = false;
                undoCreateEdgeCalled = true;
                ec = e;
            });

            var cvoSource = new CreateVertexOperation(graph, source, (sv, svc) =>
            {
                createSourceCalled = true;
                sourceVC = svc;
            },
            (v) =>
            {
                undoCreateSourceCalled = true;
            });

            var cvoTarget = new CreateVertexOperation(graph, target, (sv, svc) =>
            {
                createTargetCalled = true;
                targetVC = svc;
            },
            (v) =>
            {
                undoCreateTargetCalled = true;
            });

            cvoSource.Do();

            Assert.IsTrue(createSourceCalled);
            Assert.IsNotNull(sourceVC);
            Assert.IsTrue(graph.Graph.Vertices.Any(v => v == source));
            Assert.AreEqual(source, sourceVC.Vertex, "source are not equal");

            cvoTarget.Do();

            Assert.IsTrue(createTargetCalled);
            Assert.IsNotNull(targetVC);
            Assert.IsTrue(graph.Graph.Vertices.Any(v => v == target));
            Assert.AreEqual(target, targetVC.Vertex, "target are not equal");

            ceo.Do();

            Assert.IsTrue(createEdgeCalled);
            Assert.IsNotNull(ec);
            Assert.IsTrue(graph.Graph.Vertices.Any(v => v == source));
            Assert.IsTrue(graph.Graph.Vertices.Any(v => v == target));
            Assert.IsTrue(graph.Graph.Edges.Any(e => e == ec.Edge));
            Assert.AreEqual<VertexControl>(ec.Source, sourceVC, "source vertex control are not equal");
            Assert.AreEqual<VertexControl>(ec.Target, targetVC, "target vertex control are not equal");

            ceo.UnDo();

            Assert.IsTrue(undoCreateEdgeCalled);
            Assert.IsNotNull(ec);
            Assert.IsNull(ec.Edge);
            Assert.IsTrue(graph.Graph.Vertices.Any(v => v == source));
            Assert.IsTrue(graph.Graph.Vertices.Any(v => v == target));
            Assert.IsFalse(graph.Graph.Edges.Any(e => e == ec.Edge));
            Assert.AreEqual<VertexControl>(ec.Source, null, "source sould be null");
            Assert.AreEqual<VertexControl>(ec.Target, null, "target sould be null");

            //redo
            ceo.Do();

            Assert.IsTrue(createEdgeCalled);
            Assert.IsNotNull(ec);
            Assert.IsTrue(graph.Graph.Vertices.Any(v => v == source));
            Assert.IsTrue(graph.Graph.Vertices.Any(v => v == target));
            Assert.IsTrue(graph.Graph.Edges.Any(e => e == ec.Edge));
            Assert.AreEqual<VertexControl>(ec.Source, sourceVC, "source are not equal");
            Assert.AreEqual<VertexControl>(ec.Target, targetVC, "target are not equal");

            ceo.UnDo();

            Assert.IsTrue(undoCreateEdgeCalled);
            Assert.IsNotNull(ec);
            Assert.IsNull(ec.Edge);
            Assert.IsTrue(graph.Graph.Vertices.Any(v => v == source));
            Assert.IsTrue(graph.Graph.Vertices.Any(v => v == target));
            Assert.IsFalse(graph.Graph.Edges.Any(e => e == ec.Edge));
            Assert.AreEqual<VertexControl>(ec.Source, null, "source sould be null");
            Assert.AreEqual<VertexControl>(ec.Target, null, "target sould be null");

            cvoSource.UnDo();

            Assert.IsTrue(undoCreateSourceCalled);
            Assert.IsNotNull(sourceVC);
            Assert.IsFalse(graph.Graph.Vertices.Any(v => v == source));
            Assert.IsNull(sourceVC.Vertex, "source sould be null");

            cvoTarget.UnDo();

            Assert.IsTrue(undoCreateTargetCalled);
            Assert.IsNotNull(targetVC);
            Assert.IsFalse(graph.Graph.Vertices.Any(v => v == target));
            Assert.IsNull(targetVC.Vertex, "target sould be null");
        }
        public void UpdateVertex(DataVertex vertex, Action<bool, DataVertex, Exception> onComplete)
        {

        }