コード例 #1
0
        internal void AddFrequentPattern(PatternTree fpt)
        {
            if (!Frequents.ContainsKey(fpt.PreorderString))
            {
                Frequents.Add(fpt.PreorderString, fpt);
            }

            if (fpt.Is1Pattern && !Frequent1Pts.ContainsKey(fpt.PreorderString))
            {
                Frequent1Pts.Add(fpt.PreorderString, fpt);
                return;
            }

            if (fpt.Is2Pattern && !Frequent2Pts.ContainsKey(fpt.PreorderString))
            {
                Frequent2Pts.Add(fpt.PreorderString, fpt);
            }

            for (Depth d = 0; d < MaxDepth; d++)
            {
                if (fpt.ContainsDepth(d) && !DepthBasedFrequentPts[d].ContainsKey(fpt.PreorderString))
                {
                    DepthBasedFrequentPts[d].Add(fpt.PreorderString, fpt);
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Добавление частого поддерева
 /// </summary>
 /// <param name="freqSubtree">Частое поддерево</param>
 internal void AddFrequentSubtree(Tree freqSubtree)
 {
     if (!Frequents.ContainsKey(freqSubtree.DfsString))
     {
         Frequents.Add(freqSubtree.DfsString, freqSubtree);
     }
     if (freqSubtree.Is1NodeTree && !Frequent1NodeTrees.ContainsKey(freqSubtree.DfsString))
     {
         Frequent1NodeTrees.Add(freqSubtree.DfsString, freqSubtree);
         return;
     }
     if (freqSubtree.Is2NodeTree && !Frequent2NodesTrees.ContainsKey(freqSubtree.DfsString))
     {
         Frequent2NodesTrees.Add(freqSubtree.DfsString, freqSubtree);
     }
     for (int d = 0; d < MaxDepth; d++)
     {
         if (freqSubtree.ContainsDepth(d) && !DepthBasedFrequentTrees[d].ContainsKey(freqSubtree.DfsString))
         {
             DepthBasedFrequentTrees[d].Add(freqSubtree.DfsString, freqSubtree);
         }
     }
 }