Пример #1
0
        public void DeleteNode_ShouldDeleteNodeInfo()
        {
            var node = graph.AddNode();

            graph.DeleteNode(node);
            Assert.Throws <KeyNotFoundException>(() =>
            {
                var nodeInfo = graph.NodeInfos[node];
            });
        }
Пример #2
0
        private void imDrawSpace_MouseUp(object sender, MouseEventArgs e)
        {
            if (nodesEdgesState == NodesEdges.Nodes)
            {
                switch (clickState)
                {
                case ClickStates.Add:
                    clickedNode = graph.AddNode(x, y, Color.White);
                    break;

                case ClickStates.Delete:
                    if (clickedNode != null)
                    {
                        graph.DeleteNode(clickedNode);
                    }
                    break;

                case ClickStates.Move:
                    break;
                }
            }
            else
            {
                switch (clickState)
                {
                case ClickStates.Add:
                    if (selectedNode != null && selectedNode != clickedNode)
                    {
                        IEdge edge = graph.AddEdge(clickedNode, selectedNode, DefaultLength);
                    }
                    break;

                case ClickStates.Delete:
                    graph.DeleteEdge(clickedEdge);
                    break;
                }
            }
            clickedNode = null;
            clickedEdge = null;
            clickState  = ClickStates.NoClick;
            draw();
        }