コード例 #1
0
        public void RemoveNode(int numNodes, int numEdges, bool isDirected, bool selfLoops, bool multiEdges, int[] indicesToRemove)
        {
            ISimpleAdjList net = SimpleAdjListGenerator.GenerateAdjList(numNodes, numEdges, isDirected, selfLoops, multiEdges);

            SimpleAdjListEditor editor = new SimpleAdjListEditor();

            int removed = editor.RemoveNode(net, indicesToRemove[0]);

            Assert.IsNotNull(net, "Outputnet should not be null");

            int check = net.NodeCount + removed;
            Assert.AreEqual(numNodes, check, "Check of removed should match expected");
            Assert.AreEqual(numNodes - removed, net.NodeCount, "new node count should match expected");

            // re-verify new indices
            INode node = null;
            for (int i = 0; i < net.NodeCount; i++)
            {
                node = net.Nodes[i];
                Assert.IsNotNull(node, "New node indexed should not be null");
            }
        }
コード例 #2
0
        public void RemoveNode_WhenNodeDataMapIsPresent(int testId, int[] indicesToRemove, Type dataType, object defaultVal, int nodeCount, int edgeCount, bool directed, bool selfLoops, bool multiEdges)
        {
            ISimpleAdjList net = SimpleAdjListGenerator.GenerateAdjList(nodeCount, edgeCount, directed, selfLoops, multiEdges);
            SimpleAdjListAttributeListDataBuilder builder = new SimpleAdjListAttributeListDataBuilder(AttributeListType.Node);
            builder.AddList(net, dataType);

            SimpleAdjListEditor editor = new SimpleAdjListEditor();

            int removed = editor.RemoveNode(net, indicesToRemove[0]);

            Assert.IsNotNull(net, "Outputnet should not be null");

            int check = net.NodeCount + removed;
            Assert.AreEqual(nodeCount, check, "Check of removed should match expected");
            Assert.AreEqual(nodeCount - removed, net.NodeCount, "new node count should match expected");

            // re-verify new indices
            INode node = null;
            for (int i = 0; i < net.NodeCount; i++)
            {
                node = net.Nodes[i];
                Assert.IsNotNull(node, "New node indexed should not be null");
            }
        }