当前位置: 首页>>代码示例>>C#>>正文


C# BasicAdjList.RemoveNode方法代码示例

本文整理汇总了C#中BlueSpider.Blob.Basic.Network.AdjList.BasicAdjList.RemoveNode方法的典型用法代码示例。如果您正苦于以下问题:C# BasicAdjList.RemoveNode方法的具体用法?C# BasicAdjList.RemoveNode怎么用?C# BasicAdjList.RemoveNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BlueSpider.Blob.Basic.Network.AdjList.BasicAdjList的用法示例。


在下文中一共展示了BasicAdjList.RemoveNode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveNode_With_2_Nodes_And_1_Edge

        public void RemoveNode_With_2_Nodes_And_1_Edge()
        {
            //Arrange
            var net = new BasicAdjList(Guid.NewGuid());
            BasicNode nodeA = net.CreateNode() as BasicNode;
            BasicNode nodeB = net.CreateNode() as BasicNode;
            IEdge edge = net.CreateEdge(nodeA, nodeB);

            Assert.Equal(2, net.NodeCount);
            Assert.Equal(2, net.Nodes.Count);
            Assert.Equal(1, net.EdgeCount);
            Assert.Equal(1, net.Edges.Count);

            Assert.Equal(1, nodeA.EdgeList.Count);
            Assert.Equal(1, nodeA.Degree);
            Assert.Equal(0, nodeA.InDegree);
            Assert.Equal(1, nodeA.OutDegree);
            Assert.Equal(1, nodeB.EdgeList.Count);
            Assert.Equal(1, nodeB.Degree);
            Assert.Equal(1, nodeB.InDegree);
            Assert.Equal(0, nodeB.OutDegree);

            net.RemoveNode(nodeA);

            Assert.Equal(1, net.NodeCount);
            Assert.Equal(1, net.Nodes.Count);
            Assert.Equal(0, net.EdgeCount);
            Assert.Equal(0, net.Edges.Count);

            Assert.Equal(0, nodeA.EdgeList.Count);
            Assert.Equal(0, nodeA.Degree);
            Assert.Equal(0, nodeA.InDegree);
            Assert.Equal(0, nodeA.OutDegree);
            Assert.Equal(0, nodeB.EdgeList.Count);
            Assert.Equal(0, nodeB.Degree);
            Assert.Equal(0, nodeB.InDegree);
            Assert.Equal(0, nodeB.OutDegree);
        }
开发者ID:BgRva,项目名称:Blob1,代码行数:38,代码来源:BasicAdjListFixture.cs

示例2: RemoveNode_WithSelfLoop

        public void RemoveNode_WithSelfLoop()
        {
            //Arrange
            var net = new BasicAdjList(Guid.NewGuid());
            INode nodeA = net.CreateNode();
            INode nodeB = net.CreateNode();
            INode nodeC = net.CreateNode();
            IEdge edge0 = net.CreateEdge(nodeB, nodeC);
            IEdge edge1 = net.CreateEdge(nodeA, nodeA);

            bool result = nodeA.SuccessorList.Contains(nodeA);
            Assert.True(result);
            result = nodeA.PredecessorList.Contains(nodeA);
            Assert.True(result);

            Assert.Equal(1, nodeA.SuccessorList.Count);
            Assert.Equal(1, nodeA.PredecessorList.Count);

            net.RemoveNode(nodeA);

            result = nodeA.SuccessorList.Contains(nodeA);
            Assert.False(result);
            result = nodeA.PredecessorList.Contains(nodeA);
            Assert.False(result);

            Assert.Equal(0, nodeA.SuccessorList.Count);
            Assert.Equal(0, nodeA.PredecessorList.Count);
        }
开发者ID:BgRva,项目名称:Blob1,代码行数:28,代码来源:BasicAdjListFixture.cs

示例3: RemoveNode_With_2_Nodes

        public void RemoveNode_With_2_Nodes()
        {
            //Arrange
            var net = new BasicAdjList(Guid.NewGuid());
            INode nodeA = net.CreateNode();
            INode nodeB = net.CreateNode();

            Assert.Equal(2, net.NodeCount);
            Assert.Equal(2, net.Nodes.Count);
            Assert.Equal(0, net.EdgeCount);
            Assert.Equal(0, net.Edges.Count);

            net.RemoveNode(nodeB);

            Assert.Equal(1, net.NodeCount);
            Assert.Equal(1, net.Nodes.Count);
            Assert.Equal(0, net.EdgeCount);
            Assert.Equal(0, net.Edges.Count);
        }
开发者ID:BgRva,项目名称:Blob1,代码行数:19,代码来源:BasicAdjListFixture.cs

示例4: RemoveNode_Throws_When_Invalid_Type_Passed_In_For_Dest_Node

 public void RemoveNode_Throws_When_Invalid_Type_Passed_In_For_Dest_Node()
 {
     //Arrange
     var net = new BasicAdjList(Guid.NewGuid());
     var ex = Assert.Throws<ArgumentException>(() => net.RemoveNode(new DummyBasicNode()));
 }
开发者ID:BgRva,项目名称:Blob1,代码行数:6,代码来源:BasicAdjListFixture.cs

示例5: RemoveNode_Throws_When_Null_Passed_In

 public void RemoveNode_Throws_When_Null_Passed_In()
 {
     //Arrange
     var net = new BasicAdjList(Guid.NewGuid());
     var ex = Assert.Throws<ArgumentNullException>(() => net.RemoveNode(null));
 }
开发者ID:BgRva,项目名称:Blob1,代码行数:6,代码来源:BasicAdjListFixture.cs

示例6: RemoveNode_Fuzz3

        public void RemoveNode_Fuzz3(int targetNodeIndex, int initDegree, int initPredCount, int initSuccCount, int expectedNodeCount, int expectedEdgeCount)
        {
            //Arrange
            var net = new BasicAdjList(Guid.NewGuid());
            INode nodeA = net.CreateNode();
            INode nodeB = net.CreateNode();
            INode nodeC = net.CreateNode();
            INode nodeD = net.CreateNode();
            INode nodeE = net.CreateNode();
            INode nodeF = net.CreateNode();

            IEdge e0 = net.CreateEdge(nodeA, nodeA);
            IEdge e1 = net.CreateEdge(nodeC, nodeA);
            IEdge e2 = net.CreateEdge(nodeE, nodeC);
            IEdge e3 = net.CreateEdge(nodeE, nodeE);
            IEdge e4 = net.CreateEdge(nodeD, nodeB);

            INode targetNode = net.Nodes[targetNodeIndex];

            Assert.NotNull(targetNode.Network);
            Assert.Equal(initDegree, targetNode.Degree);
            Assert.Equal(initPredCount, targetNode.PredecessorList.Count);
            Assert.Equal(initSuccCount, targetNode.SuccessorList.Count);

            net.RemoveNode(targetNode);

            Assert.Null(targetNode.Network);
            Assert.Equal(0, targetNode.Degree);
            Assert.Equal(0, targetNode.PredecessorList.Count);
            Assert.Equal(0, targetNode.SuccessorList.Count);
            Assert.Equal(0, ((BasicNode)targetNode).EdgeList.Count);

            Assert.Equal(expectedNodeCount, net.NodeCount);
            Assert.Equal(expectedEdgeCount, net.EdgeCount);
        }
开发者ID:BgRva,项目名称:Blob1,代码行数:35,代码来源:BasicAdjListFixture.cs

示例7: RemoveNode_Throws_Ex_If_Edge_DNE_In_Network

        public void RemoveNode_Throws_Ex_If_Edge_DNE_In_Network()
        {
            //Arrange
            var net = new BasicAdjList(Guid.NewGuid());
            INode nodeA = net.CreateNode();
            INode nodeB = net.CreateNode();
            IEdge edge0 = net.CreateEdge(nodeA, nodeB);

            var net2 = new BasicAdjList(Guid.NewGuid());
            INode node0 = net2.CreateNode();

            var ex = Assert.Throws<ArgumentException>(() => net.RemoveNode(node0));
        }
开发者ID:BgRva,项目名称:Blob1,代码行数:13,代码来源:BasicAdjListFixture.cs

示例8: RemoveNode_Fuzz

        public void RemoveNode_Fuzz()
        {
            //Arrange
            var net = new BasicAdjList(Guid.NewGuid());
            INode nodeA = net.CreateNode();
            INode nodeB = net.CreateNode();
            INode nodeC = net.CreateNode();
            INode nodeD = net.CreateNode();
            INode nodeE = net.CreateNode();

            IEdge e0 = net.CreateEdge(nodeA, nodeB);
            IEdge e1 = net.CreateEdge(nodeC, nodeB);
            IEdge e2 = net.CreateEdge(nodeC, nodeD);
            IEdge e3 = net.CreateEdge(nodeE, nodeE);

            Assert.NotNull(nodeB.Network);
            Assert.Equal(1, nodeA.Degree);
            Assert.Equal(2, nodeB.Degree);
            Assert.Equal(2, nodeC.Degree);
            Assert.Equal(1, nodeD.Degree);
            Assert.Equal(2, nodeE.Degree);

            Assert.Equal(0, nodeA.PredecessorList.Count);
            Assert.Equal(2, nodeB.PredecessorList.Count);
            Assert.Equal(0, nodeC.PredecessorList.Count);
            Assert.Equal(1, nodeD.PredecessorList.Count);
            Assert.Equal(1, nodeE.PredecessorList.Count);
            Assert.Equal(1, nodeA.SuccessorList.Count);
            Assert.Equal(0, nodeB.SuccessorList.Count);
            Assert.Equal(2, nodeC.SuccessorList.Count);
            Assert.Equal(0, nodeD.SuccessorList.Count);
            Assert.Equal(1, nodeE.SuccessorList.Count);

            net.RemoveNode(nodeB);

            Assert.Equal(0, nodeA.Degree);
            //
            Assert.Equal(1, nodeC.Degree);
            Assert.Equal(1, nodeD.Degree);
            Assert.Equal(2, nodeE.Degree);

            Assert.Equal(0, nodeA.PredecessorList.Count);
            //
            Assert.Equal(0, nodeC.PredecessorList.Count);
            Assert.Equal(1, nodeD.PredecessorList.Count);
            Assert.Equal(1, nodeE.PredecessorList.Count);
            Assert.Equal(0, nodeA.SuccessorList.Count);
            //
            Assert.Equal(1, nodeC.SuccessorList.Count);
            Assert.Equal(0, nodeD.SuccessorList.Count);
            Assert.Equal(1, nodeE.SuccessorList.Count);

            Assert.Null(nodeB.Network);
            Assert.Equal(0, nodeB.Degree);
            Assert.Equal(0, ((BasicNode)nodeB).EdgeList.Count);
            Assert.Equal(0, nodeB.PredecessorList.Count);
            Assert.Equal(0, nodeB.SuccessorList.Count);

            Assert.Null(e0.Network);
            Assert.Null(e0.SourceNode);
            Assert.Null(e0.DestinationNode);

            Assert.Null(e1.Network);
            Assert.Null(e1.SourceNode);
            Assert.Null(e1.DestinationNode);
        }
开发者ID:BgRva,项目名称:Blob1,代码行数:66,代码来源:BasicAdjListFixture.cs

示例9: RemoveNode_DoesNotAffectNodeAccessorAndPredecessorLists

        public void RemoveNode_DoesNotAffectNodeAccessorAndPredecessorLists()
        {
            //Arrange
            var net = new BasicAdjList(Guid.NewGuid());
            Type expectedType = typeof(BasicEdge);
            INode nodeA = net.CreateNode();
            INode nodeB = net.CreateNode();
            IEdge edge = net.CreateEdge(nodeA, nodeB);

            bool result = nodeA.SuccessorList.Contains(nodeB);
            Assert.True(result);
            result = nodeA.PredecessorList.Contains(nodeB);
            Assert.False(result);

            result = nodeB.PredecessorList.Contains(nodeA);
            Assert.True(result);
            result = nodeB.SuccessorList.Contains(nodeA);
            Assert.False(result);

            net.RemoveNode(nodeB);

            result = nodeA.SuccessorList.Contains(nodeB);
            Assert.False(result);
            result = nodeA.PredecessorList.Contains(nodeB);
            Assert.False(result);

            result = nodeB.PredecessorList.Contains(nodeA);
            Assert.False(result);
            result = nodeB.SuccessorList.Contains(nodeA);
            Assert.False(result);
        }
开发者ID:BgRva,项目名称:Blob1,代码行数:31,代码来源:BasicAdjListFixture.cs

示例10: RemoveNode_Removes_Row_With_Matching_Key_In_NodeData

        public void RemoveNode_Removes_Row_With_Matching_Key_In_NodeData(int nodeCount, int [] removalIndices)
        {
            var net = new BasicAdjList(Guid.NewGuid());
            var table = new DataAttributeTable<INode>();
            table.Network = net;
            net.NodeData = table;

            IList<INode> nodes = new List<INode>();
            for (int i = 0; i < nodeCount; i++)
            {
                nodes.Add(net.CreateNode());
                Assert.Equal((i + 1), net.NodeCount);
                Assert.Equal((i + 1), table.RowCount);
                Assert.True(table.RowOwnerMap.ContainsKey(nodes[i]));
            }

            INode nodeToRemove = null;
            int ctr = 0;
            var count = net.NodeCount;
            for (int i = 0; i < removalIndices.Length; i++)
            {
                ctr++;
                nodeToRemove = nodes[removalIndices[i]];
                net.RemoveNode(nodeToRemove);
                Assert.Equal((count - ctr), net.NodeCount);
                Assert.Equal((count - ctr), table.RowCount);
                Assert.False(table.RowOwnerMap.ContainsKey(nodeToRemove));
            }
        }
开发者ID:BgRva,项目名称:Blob1,代码行数:29,代码来源:BasicAdjList_DataAttributes_Fixture.cs

示例11: ChangeEventsEnabled_When_False_Prevents_NetworkChanged_Fired_When_RemoveNode_Is_Called

        public void ChangeEventsEnabled_When_False_Prevents_NetworkChanged_Fired_When_RemoveNode_Is_Called(int nodeCount, int removeCount)
        {
            //Arrange
            var net = new BasicAdjList(Guid.NewGuid());
            for (int i = 0; i < nodeCount; i++)
                net.CreateNode();
            //---------------------

            var helper = new NetworkChangedEventsTestHelper();
            net.NetworkChanged += new NetworkChangedEventHandler<INetwork, NetworkChangedEventArgs>(helper.NetworkChanged_DummyHandler);

            net.ChangeEventsEnabled = false;
            for (int i = 0; i < removeCount; i++)
            {
                net.RemoveNode(net.Nodes[0]);
            }

            Assert.Equal(0, helper.NetworkChanged_TimesCalled);
        }
开发者ID:BgRva,项目名称:Blob1,代码行数:19,代码来源:BasicAdjList_As_INetworkChangeEventsFixture.cs

示例12: NetworkChanged_Args_Contains_Node_After_RemoveNode_Is_Called

        public void NetworkChanged_Args_Contains_Node_After_RemoveNode_Is_Called()
        {
            //Arrange
            var net = new BasicAdjList(Guid.NewGuid());
            var helper = new NetworkChangedEventsTestHelper();
            net.NetworkChanged += new NetworkChangedEventHandler<INetwork, NetworkChangedEventArgs>(helper.NetworkChanged_DummyHandler);
            var nodeA = net.CreateNode();
            var nodeB = net.CreateNode();
            var nodeC = net.CreateNode();

            helper.Reset();
            net.RemoveNode(nodeB);

            var argItem = helper.LastArgumentRecieved.NodeRemoved;
            Assert.Same(argItem, nodeB);
        }
开发者ID:BgRva,项目名称:Blob1,代码行数:16,代码来源:BasicAdjList_As_INetworkChangeEventsFixture.cs


注:本文中的BlueSpider.Blob.Basic.Network.AdjList.BasicAdjList.RemoveNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。