Ejemplo n.º 1
0
        /// <summary>
        /// ������е�ģʽ
        /// ��ȡ�Ӽ��㷨
        /// </summary>
        /// <param name="_treeNodeItemList"></param>
        public void CombineNodes(FPTree _fpTree, List<ItemSet> _itemSetList)
        {
            //��ȡ���н��
            List<TreeNodeItem> _treeNodeItemList = new List<TreeNodeItem>();
            TreeNodeItem _treeNodeItem = _fpTree.TopNode;
            bool _hasNext = (_treeNodeItem.Nodes.Count > 0);
            _treeNodeItem = _treeNodeItem.Nodes[0];
            while (_hasNext)
            {
                _treeNodeItemList.Add(_treeNodeItem);
                if (_treeNodeItem.Nodes.Count > 0)
                    _treeNodeItem = _treeNodeItem.Nodes[0];
                else
                    _hasNext = false;
            }

            int _length = _treeNodeItemList.Count;
            //��1��ʼ,��Ϊ��ȡ�ռ�
            for (int i = 1; i < Math.Pow(2, _length); i++)
            {
                String str = Convert.ToString(int.Parse(i.ToString()), 2);
                str = str.PadLeft(_length, '0');
                char[] _arrChr = str.ToCharArray();
                ItemSet _itemSet = new ItemSet();
                for (int j = _arrChr.Length-1; j >-1; j--)
                {
                    if (_arrChr[j] == '1')
                    {
                        _itemSet.Content.Add(_treeNodeItemList[j].ItemName);
                        if (_itemSet.Count == 0)
                            _itemSet.Count = _treeNodeItemList[j].Count;
                        else
                        {
                            //֧�ֶȵ��ڦ��н����С��֧�ֶȼ���
                            if(_treeNodeItemList[j].Count < _itemSet.Count)
                            _itemSet.Count = _treeNodeItemList[j].Count;
                        }
                    }
                }
                if(_itemSet.Content.Count!=0)
                    _itemSetList.Add(_itemSet);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// ��Ϊ��ʱ����ģʽ
 /// </summary>
 /// <param name="_itemSetConbine">����Ħ� = a(i)�Ȧ�</param>
 private void AddPattern(List<TreeNodeItem> _itemSetConbine,FPTree _fpTree)
 {
     //����ģʽ
     if (!_frequentPattern.ContainsKey(_itemSetConbine.Count))
     {
         List<ItemSet> _tmpItemSetList = new List<ItemSet>();
         ItemSet _tmpItemSet = new ItemSet();
         //����ģʽ
         foreach (TreeNodeItem _nodes in _itemSetConbine)
         {
             _tmpItemSet.Content.Add(_nodes.ItemName);
         }
         _tmpItemSet.Count =
                 _fpTree.GetSupCountByID(
                 _itemSetConbine[0].ItemName);
         _tmpItemSetList.Add(_tmpItemSet);
         _frequentPattern.Add(_itemSetConbine.Count, _tmpItemSetList);
     }
     else
     {
         List<ItemSet> _tmpItemSetList = (List<ItemSet>)_frequentPattern[_itemSetConbine.Count];
         ItemSet _tmpItemSet = new ItemSet();
         //����/���������
         foreach (TreeNodeItem _nodes in _itemSetConbine)
         {
             _tmpItemSet.Content.Add(_nodes.ItemName);
         }
         _tmpItemSet.Count =
                 _fpTree.GetSupCountByID(
                 _itemSetConbine[0].ItemName);
         _tmpItemSetList.Add(_tmpItemSet);
         //_frequentPattern[_itemSetConbine.Count] = _tmpItemSetList;
     }
 }