示例#1
0
        private PatternTree Combine2Patterns(PatternTree px, PatternTree py, Depth depth)
        {
            var preList = px.CombinePreorderRepresentation(py);
            var child   = PatternTree.Create(preList, false, MiningParams);

            PatternsExtended.AddPattern(child);
            var curDepth = depth + 1;

            while (--curDepth >= 0)
            {
                if (!px.ContainsDepth(curDepth) || !py.ContainsDepth(curDepth))
                {
                    continue;
                }

                foreach (TreeOccSet tSet in px[curDepth].GetTreeSet())
                {
                    if (!py.ContainsTreeAtDepth(curDepth, tSet.TreeId))
                    {
                        continue;
                    }
                    foreach (RootOcc root in tSet.GetRootSet())
                    {
                        if (!py.ContainsRootIndex(curDepth, tSet.TreeId, root.RootIndex))
                        {
                            continue;
                        }

                        var xOcc = px.GetOccurrence(curDepth, tSet.TreeId, root.RootIndex);
                        var yOcc = py.GetFirstOccAfterSpecifiedIndex(xOcc.Depth, xOcc.TreeId, xOcc.RootIndex, xOcc.RightMostIndex);

                        if (yOcc == null)
                        {
                            continue;
                        }

                        child.AddOccurrence(xOcc.Combine(yOcc));
                    }
                }
            }

            if (!child.IsFrequent)
            {
                return(null);
            }

            PatternsFrequent.AddFrequentPattern(child);

            child.Father = px;
            child.Mother = py;

            px.CheckMatch(child);
            py.CheckMatch(child);

            return(child);
        }