/// <summary> /// Поиск частых поддеревьев в XML-деревьях /// </summary> /// <param name="nodeList">Список узлов деревьев</param> /// <param name="support">Поддержка</param> /// <param name="minNodeNumber">Минимальное число узлов</param> /// <param name="maxNodeNumber">Максимальное число узлов</param> /// <returns>Список частых поддеревьев</returns> public static SearchResult Mine(List <XMLNode> nodeList, double support, int minNodeNumber, int maxNodeNumber /*, long maxTimeSeconds*/) { List <string> trees = InitializeTreeEncodings(nodeList, TextTreeEncoding.Separator, TextTreeEncoding.UpSign); List <TextTreeEncoding> encList = new List <TextTreeEncoding>(); foreach (string treeEncoding in trees) { TextTreeEncoding newTree = EncodingBuilder.ConvertToTextTreeEncoding(treeEncoding); if (newTree != null) { Algorithm.Canonicalize(newTree); DfsIndexBuilder.BuildDfsIndex(newTree); encList.Add(newTree); } } SearchParameters searchParams = new SearchParameters(support, minNodeNumber, maxNodeNumber); SearchParameters.treeNumber = encList.Count; //SearchParameters.maxTime = maxTimeSeconds * 1000; //в миллисекундах SearchParameters.initialTrees = encList; SubtreeMiner treeMiner = new SubtreeMiner(searchParams); SearchResult miningResult = treeMiner.Mine(encList); miningResult.SearchParams = new SearchParameters(support, minNodeNumber, maxNodeNumber); miningResult.FrequentSubtrees = PruneSubtrees(miningResult.FrequentSubtrees, searchParams.MinimumNodeNumber, searchParams.MaximumNodeNumber); return(miningResult); }
/// <summary> /// Проверка наличия поддерева по кодировкам /// </summary> /// <param name="treeEncoding">Кодировка дерева</param> /// <param name="subtreeEncoding">Кодировка поддерева</param> /// <param name="markedTree">Кодировка дерева с пометками узлов поддерева</param> /// <returns>true, если дерево содержит заданное поддерева</returns> public static bool ContainsSubtree(string treeEncoding, string subtreeEncoding, out TreeNode markedTree) { TextTreeEncoding treeEncodingObject = EncodingBuilder.ConvertToTextTreeEncodingWithoutTreeId(treeEncoding); TextTreeEncoding subtreeEncodingObject = EncodingBuilder.ConvertToTextTreeEncodingWithoutTreeId(subtreeEncoding); bool isSubtree = subtreeEncodingObject.Root.IsContainedIn(treeEncodingObject.Root); markedTree = isSubtree ? treeEncodingObject.Root : null; return(isSubtree); }