Esempio n. 1
0
        public void DeleteEdge_ShouldDeleteEdgeInfo()
        {
            var node1  = graph.AddNode();
            var node2  = graph.AddNode();
            var edge12 = graph.AddEdge(node1, node2, 1, Color.Black);

            graph.DeleteEdge(edge12);
            Assert.Throws <KeyNotFoundException>(() =>
            {
                var edgeInfo = graph.EdgeInfos[edge12];
            });
        }
Esempio n. 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();
        }