Esempio n. 1
0
        public void GetItemPrefixPath_TwoTransactionWithTheSamePrefixAdded_ReturnsPathWithOneItem()
        {
            FPTree tree = new FPTree();

            tree.AddTransaction(Transaction.Create(2, 3));
            tree.AddTransaction(Transaction.Create(2, 3, 4));

            FPTreePrefixPathItem[] path = tree.GetItemPrefixPath(2).ToArray();

            Assert.AreEqual(1, path.Length);
            Assert.AreEqual(2, path[0].FPTreeNode.Support);
        }
Esempio n. 2
0
        public void GetHeaderItemPath_TwoTransactionWithTheSameItemOnDifferentPositionAdded_ReturnsPathWithTwoItems()
        {
            FPTree tree = new FPTree();

            tree.AddTransaction(Transaction.Create(1, 2, 3));
            tree.AddTransaction(Transaction.Create(2, 3, 4));

            FPTreePrefixPathItem[] path = tree.GetItemPrefixPath(2).ToArray();

            Assert.AreEqual(2, path.Length);
            Assert.AreEqual(1, path[0].FPTreeNode.Support);
            Assert.AreEqual(1, path[1].FPTreeNode.Support);
        }
Esempio n. 3
0
        public void GetItemPrefixPath_OneTransactionAdded_CanTraverseTransaction()
        {
            FPTree tree = new FPTree();

            UInt32[] items = { 1, 2, 3, 4, 5 };
            tree.AddTransaction(Transaction.Create(items));

            FPTreeNode leafNode = tree.GetItemPrefixPath(5).ToArray()[0].FPTreeNode;

            Assert.AreEqual(5, leafNode.Item);
            Assert.AreEqual(4, leafNode.ParentNode.Item);
            Assert.AreEqual(3, leafNode.ParentNode.ParentNode.Item);
            Assert.AreEqual(2, leafNode.ParentNode.ParentNode.ParentNode.Item);
            Assert.AreEqual(1, leafNode.ParentNode.ParentNode.ParentNode.ParentNode.Item);
            Assert.AreEqual(FPTreeNodeType.Root, leafNode.ParentNode.ParentNode.ParentNode.ParentNode.ParentNode.Type);
        }
Esempio n. 4
0
        public void GetHeaderItemPath_TwoSameTransactionAdded_AllPathHaveOneItem()
        {
            FPTree tree = new FPTree();

            UInt32[] items = { 1, 2, 3, 4 };

            tree.AddTransaction(Transaction.Create(items));
            tree.AddTransaction(Transaction.Create(items));

            foreach (var item in items)
            {
                FPTreePrefixPathItem[] itemPath = tree.GetItemPrefixPath(item).ToArray();

                Assert.AreEqual(1, itemPath.Length);
                Assert.AreEqual(2, itemPath[0].FPTreeNode.Support);
            }
        }