예제 #1
0
        public void Components()
        {
            mtg tree = new mtg();
            int root = tree.root;

            // Scale 1

            int root1   = tree.AddComponent(root);
            int vertex1 = tree.AddChild(root1);
            int vertex2 = tree.AddChild(root1);
            int vertex3 = tree.AddChild(root1);
            int vertex4 = tree.AddChild(vertex1);
            int vertex5 = tree.AddChild(vertex1);

            // Verifications

            Assert.AreEqual(6, tree.NbComponents(root));

            List <int> expectedListOfComponents = new List <int>()
            {
                root1, vertex1, vertex4, vertex5, vertex2, vertex3
            };

            CollectionAssert.AreEqual(expectedListOfComponents, tree.Components(root));

            Assert.AreEqual(tree.NbComponents(root1), 0);
            Assert.AreEqual(tree.NbComponents(vertex1), 0);
            Assert.AreEqual(tree.NbComponents(vertex2), 0);
        }