/// <summary> /// Соединение поддеревьев на заданной глубине /// </summary> /// <param name="depth">Глубина</param> protected override void Connect(int depth) { List <Tree> connectableTrees = FrequentSubtrees.GetConnectableAtDepth(depth); List <Tree> treesToBeConnected = FrequentSubtrees.GetToBeConnectableAtDepth(depth + 1); foreach (Tree f2 in connectableTrees) { List <Tree> toBeConnected = SelectSubtreesOfSameRoot(f2.SecondSymbol, treesToBeConnected, depth + 1); foreach (Tree t in toBeConnected) { string childDfsStr = f2.ConnectDfsRepresentation(t).ToDfsString(); if (ExtendedSubtrees.AlreadyExtended(childDfsStr)) { continue; } if (!f2.HasNewConnectEntryAtDepth(t, depth)) { continue; } Connect2Subtrees(f2, t, depth); } } PruneAfterConnection(FrequentSubtrees, SearchParams.Support, depth); }
/// <summary> /// Обход с целью комбинирования поддеревьев /// </summary> /// <param name="xTree">Дерево, с которым производится комбинация</param> /// <param name="yIndex">Индекс дерева в списке</param> /// <param name="group">Список деревьев, которые можно комбинировать с xTree</param> /// <param name="depth">Глубина</param> private void Traversal(Tree xTree, int yIndex, IList <Tree> group, int depth) { Tree treeX = xTree; Tree treeY = group[yIndex]; string childDfsStr = treeX.CombineDfsRepresentation(treeY).ToDfsString(); Tree child = null; if (ExtendedSubtrees.AlreadyExtended(childDfsStr)) { child = FrequentSubtrees.GetSubtreeAtDepth(childDfsStr, depth); } else if (treeX.HasNewCombineEntryAtDepth(treeY, depth)) { child = Combine2Subtrees(treeX, treeY, depth); } if (child == null) { return; } for (int i = 0; i < group.Count; i++) { Traversal(child, i, group, depth); } }