예제 #1
0
        public static void TestCalcLevelAllNodes()
        {
            var root = new SimpleTreeNode <int>(1, null);
            var tree = new SimpleTree <int>(root);
            var node = new SimpleTreeNode <int>(2, root);

            tree.AddChild(root, node);
            var node3 = new SimpleTreeNode <int>(3, root);

            tree.AddChild(root, node3);
            var node4 = new SimpleTreeNode <int>(4, node3);

            tree.AddChild(node3, node4);

            tree.CalcLevelAllNodes();
            Assert.AreEqual(1, root.Level);
            Assert.AreEqual(2, node.Level);
            Assert.AreEqual(2, node3.Level);
            Assert.AreEqual(3, node4.Level);
        }