{'fraction_non_alphanumeric': 0.03727671212805705, 'fraction_numerical': 0.011733678465464402, 'mean_word_length': 4.11535819124352, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 53, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Discovering Closed and Maximal Embedded Patterns from Large Tree Data

We address the problem of summarizing embedded tree patterns extracted from large data trees. We do so by defining and mining closed and maximal embedded unordered tree patterns from a single large data tree. We design an embedded frequent pattern mining algorithm extended with a local closedness checking technique. This algorithm is called {\em closedEmbTM-prune} as it eagerly eliminates non-closed patterns. To mitigate the generation of intermediate patterns, we devise pattern search space pruning rules to proactively detect and prune branches in the pattern search space which do not correspond to closed patterns. The pruning rules are accommodated into the extended embedded pattern miner to produce a new algorithm, called {\em closedEmbTM-prune}, for mining all the closed and maximal embedded frequent patterns from large data trees. Our extensive experiments on synthetic and real large-tree datasets demonstrate that, on dense datasets, {\em closedEmbTM-prune} not only generates a complete closed and maximal pattern set which is substantially smaller than that generated by the embedded pattern miner, but also runs much faster with negligible overhead on pattern pruning.

and real large-tree datasets demonstrate that, on dense datasets, closedEmbTMprune not only generates a complete closed and maximal pattern set which is substantially smaller than that generated by the embedded pattern miner, but also runs much faster with negligible overhead on pattern pruning.

Introduction
An important task in the analysis of the voluminous loosely structured datasets of big data applications is the mining of frequent patterns. Mining frequent patterns is also a core process of other important data mining processes like classification, clustering and detection of outliers and it has applications in numerous practical domains like database design, query optimization, chemical compound prediction, protein-protein interaction etc. The number of patterns produced from pattern mining is often huge. Besides the efficiency, this can also reduce the effectiveness of the mining process, since it is not realistic to comprehend and store such a large number of patterns. It is well known that the real problem in pattern mining is not the efficiency of the mining process but rather the usability of the mined frequent pattern set. One way to address this problem is to "summarize" the patterns. A high-quality pattern summarization technique essentially preserves the general information on the frequent patterns while reducing substantially the number of patterns. The framework. In this paper we study summarizing patterns extracted from large tree data. A tree is a data structure most frequently used in big data senarios. Trees organize the data in the form of hierarchies, but at the same time they have the flexibility of allowing arbitrary horizontal and vertical expansions. Trees are employed in data models like XML and JSON which are standard formats for integrating, exchanging, exporting and representing web data and in databases including (e.g., in the NoSQL database MongoDB).
Tree pattern mining has been researched extensively, because it is important for data analysis [1,27,22,2,39,29,23,19,6,42,43,15,12,26,28,25,10,16,44,31,35,36]. Two parameters characterize the tree patterns mined from the data: (a) the kind of morphism used to match the nodes of a tree pattern to the nodes of the data structure, and (b) the kind of edges the tree pattern can have. Edges can be either child edges or descendant edges. A child edge matches an edge in the data structure. A descendant edge matches a path in the data structure. In previous works, the morphisms adopted are almost exclusively embeddings. Embeddings are injections which preserve node labels and not-on-the-same-path relationships between the pattern nodes [42,43]. When an embedding matches the edges of the tree pattern to edges in the data tree (that is, the edges of the pattern are seen as child edges), it is an isomorphism [6,16].
Initially, the extracted tree patterns were induced patterns [1,22,2,39,23,29,6,15,12,28,10,16]. Induced patterns are matched to the data structure through isomorphisms and, of course, they contain exclusively child edges. Gradually, the mined tree patterns evolved to embedded patterns [42,43,26,25,44,31,36]. Embedded patterns generalize induced patterns since they are matched to the data structure through embeddings, and contain exclusively descendant edges. In this sense, embedded patterns are able to discover relationships "hidden" (or embedded) deeply within the data structure which might not be discovered by induced patterns [43,42]. However, extracting embedded patterns is computationally more challenging than extracting induced patterns. For instance, the problem of checking whether an isomorphism of an unordered tree pattern with child edges exists in a tree is polynomial [17]. In contrast, the problem of checking whether an embedding of an unordered tree pattern with descendant edges exists in a tree is NP-Complete [18].
Current algorithms that mine trees almost exclusively focus on extracting patterns from a collection of small trees. Extracting patterns from a large tree was addressed only recently [31,32,36]. The large tree framework generalizes the framework of a set of small trees. Indeed, a set of small trees can be represented by a single large tree with an unlabeled virtual root. A plethora of applications input and generate datasets which are structured as a large data tree [9,30].
The present study is placed in the broad framework of mining embedded patterns from large tree data which can be a list of small trees or a single large tree. The problem. Typically, with a high frequency threshold, mining will generate only trivial patterns, while with a low frequency threshold, it will generate a huge number of patterns. This drawback seriously impedes the utility and usage of frequent-pattern mining. To address this issue, an obvious solution would be to summarize the patterns. A well-known solution for high-quality summarization consists in generating clusters of frequent patterns based on a similarity metric, and then choose and return only a representative pattern from each cluster [40]. This reduction enjoys many advantages: (a) Computing a much smaller pattern set results in improved efficiency; (b) a small number of mined patterns allows the users to examine them and understand the mining results; and (c) larger and more complex datasets can be handled. In fact, in multiple real-world scenarios, the primary goal is not the enumeration of all frequent patterns. Rather, the extracted patterns are potentially exploited as input in the following analysis or modeling phases, and therefore, a small set of representative patterns might be sufficient [14].
A popular summarization technique employed in the setting of induced patterns mined from multiple small data trees is to compute maximal and closed patterns. A frequent pattern is closed if there is no isomorphic pattern with the same support. A maximal pattern is a frequent pattern such that there is no frequent isomorphic proper superpattern. When mining patterns from multiple small trees, pattern support is the number of small trees containing the pattern. This way of measuring pattern support is called document support. Unfortunately, these definitions do not apply to the broad setting we consider in this paper because: (a) document support does not make sense in the setting of a large tree dataset, and (b) the concept of isomorphic subpattern/superpattern is not meaningful in the setting of embedded  patterns which involve embeddings and contain descendant edges. To the best of our knowledge, there is not any work on maximal or closed embedded tree patterns, even in the framework of multiple small trees. Let's look at the data tree of Figure 1(a) which integrates categorized bibliographic information from two different data sources (the book entries are omitted). We adopt root support for the patterns (the number of the distinct images of the root of the pattern under all possible embeddings of the pattern to the tree dataset) and the support threshold is 2. Figures 1(b) and (c) show some frequent embedded patterns. As one can see, pattern P of Figure 1(c) is larger in size and more informative than the other patterns. Instead of presenting to the user all these patterns, we can just present the pattern P . The patterns of Figure 1(b) might not be isomoprphic subpatterns of pattern P but they are all emdedded subpatterns of P (that is, they have an embedding to P ). Later, we introduce the concepts of embedded maximal and embedded closed pattern which can be used for clustering the embedded frequent patterns and also can act as representatives of the embedded frequent pattern clusters. Based on these definitions, it will become evident that pattern P is a closed (and a maximal) embedded frequent pattern. This fact justifies omitting the patterns of figure 1(b) on behalf of pattern P .
In this paper, we address the problem of summarizing embedded frequent unordered patterns mined from a single or multiple large data trees by defining the concepts of maximal and closed embedded tree patterns and by designing algorithms for mining those types of patterns. Contribution. The main contributions of this paper are the following: : • Defining meaningful closed and maximal patterns is tricky in the context of embedded patterns over a single large tree. Therefore, we employ a new way for defining pattern support which enjoys useful monotonic characteristics. Further, in order to account for embedded patterns, we generalize the concept of subpattern by introducing the concept of embedded subpattern. Based on these concepts, we introduce closed and maximal embedded unordered tree patterns over large tree data and study their properties. • We present a frequent pattern mining algorithm extended with a local closedness checking technique, called closedEmbTM-eager, to eagerly eliminate nonclosed patterns. To allow for closedness checking, closedEmbTM-eager computes and stores the embedded occurrence lists of all the nodes of candidate frequent patterns. • To further reduce the generation of frequent patterns which turn out to be nonclosed, we design pruning rules to proactively detect branches in the pattern search space that do not correspond to closed patterns. These branches are pruned to avoid unnecessary computations. The pruning rules are leveraged in the design of a new algorithm, named closedEmbTM-prune, for mining all the closed and maximal embedded frequent patterns from large data trees. • We conducted a comprehensive experimentation to assess the scalability and performance of our algorithms on synthetic and real datasets. We also compared with a post-processing algorithm which first extracts all frequent patterns using a state-of-the-art algorithm [36] before filtering out non-closed (or nonmaximal) ones. The experimental results show that: (a) Our algorithms generate a complete closed and maximal pattern set which is substantially smaller than the set of embedded patterns generated by an embedded pattern miner. (b) Algorithm closedEmbTM-eager outperform the baseline post-processing algorithm as the latter checks for closedness the entire frequent pattern set; this set might be exponentially larger than the closed pattern set. (c) On sparse datasets, closedEmbTM-prune has comparable time and memory performance with closedEmbTM-eager; this is due to a small overhead incurred by the application of the pattern pruning rule; (d) On dense datasets, closedEmbTM-prune outperforms in all cases closedEmbTM-eager in regard to run-time by orders of magnitude and also in regard to memory footprint and scalability. Paper outline. The following section introduces the concept of embedded subattern, formally describes the problem addressed and provides preliminary results. Section 3 sets the framework of our approach for extracting closed embedded patterns. Algorithms closedEmbTM-eager and closedEmbTM-prune are presented in Sections 4 and 5, respectively. In Section 6, we present and analyze our comparative experimental results. We review related work in Section 7. A conclusion and suggestions for future work are provided in Section Section 8. where V is a set of nodes and E ⊆ V × V is a set of edges satisfying the following properties: (1) There is a function lb, called labeling function, which maps nodes to labels. (2) Set V has a unique node called the root which has no incoming edges; (3) Every node in V is linked to the root through a unique path. A tree is ordered if it there is a predefined left-to-right order among the child nodes of each node. Otherwise, it is unordered. We define the size of a tree to be the number of its nodes. Unless stated differently, in the following trees are rooted, labeled, unordered trees. Table 1 summarizes the notation used throughout this paper.
label function on graph nodes P ′ ⊑i P pattern P ′ is an isomorphic subpattern of pattern P. P ′ ⊑e P pattern P ′ is an embedded subpattern of pattern P. Lroot(P1|P2) the set of the images of nodes n1, . . . , n k under all embedding of P2 to T , where n1, . . . , n k are are images (nodes in P2) of the root of P1 under all embeddings of P1 to P2. rml rightmost leaf of a given pattern k-pattern a pattern of size k [P ] equivalence class of pattern P P i x the pattern formed by adding a child node labeled by x to the node with position i in P as its rml. P i x ⊗c P j y child join of P i x and P j y P i x ⊗s P j y cousin join of P i x and P j occurrence relation of pattern P on T LX occurrence list of pattern node X on T OL(P ) occurrence list set of P : the set of all the occurrence lists of the nodes of P on T P1 ≤ P2 order relation on patterns defined on page 18. P ≡ P ′ patterns P and P ′ are occurrence equivalent. Table 1: Notation used throughout the paper.
An encoding scheme for data trees. We employ the regional encoding scheme [4] to encode the input data tree T in a preprocessing step. This encoding represents each node in T by a triple (begin, end, level) whose elements correspond, respectively, to the first, and last encounter of the node in a depth-first preorder traversal of T , and its level in the tree. For every label a in T , the pre-processing step produces an inverted list L a for a. List L a comprises the triples of the nodes in T labeled by a, ordered on their begin field. In Fig. 2(a) one can see a data tree T 1 and the encoding of the nodes. Nodes with the same label in T are distinguished using different subscripts (e.g., nodes a 1 and a 2 ). In Fig. 2(b) one can see the inverted lists of the labels of the tree. Tree patterns. The tree patterns considered in the literature for mining fall into two categories: patterns with child edges (that is edges representing child relationships) and patterns with descendant edges (that is edges representing descendant relationships). Patterns with descendant edges are more general since a child relationship between two nodes implies also a descendant relationship. The opposite is not true. The focus in this paper is on patterns with descendant edges which are called embedded patterns and are defined below.
Tree morphisms. In order to decide if a pattern occurs in a data tree different types of morphisms are adopted in the literature. Given a pattern P and a tree T , a homomorphism from a pattern P to a data tree T is a mapping m associating every node of P to a node in T , such that: (1) for every node x ∈ P , lb(x) = lb(m(x)); and (2) for every edge ( Different constraint versions of homomorphisms have been considered in previous mining papers: an isomorphism from pattern P to T is an injective mapping m associating every node of P to a node in T , such that: (1) for every node x of P , lb(x) = lb(m(x)); and (2) (x, y) is an edge of P if and only if (m(x), m(y)) is an edge in T . In Fig. 3 one can see the two possible isomorphisms of pattern P to the data tree T 1 shown in Fig. 2(a). Obviously, isomorphisms are special cases of homomorphisms. The patterns mined when isomorphisms are adopted for mapping the patterns to the data tree are qualified as induced [1,22,6].
Embeddings are another kind of restricted homomorphisms considered in the literature: consider a pattern P which has descendant edges. An embedding from P to T is an injective function m associating nodes in P to nodes in T , such that: (1) for every node x ∈ P , lb(x) = lb(m(x)); and (2) (x, y) is an edge in P iff m(y) is a descendant of m(x) in T . Consequently, if x 1 , . . . , x n are the child nodes of a node x in P , m(x i ) and m(x j ), i, j ∈ [1, n], i = j, are not on the same path (or coincide) in T . We term this constraint satisfied by embeddings sibling constraint. Obviously, an embedding is also a restricted case of a homomorphism. In Fig. 3 one can see the data tree T 1 of Fig. 2(a), a pattern P and four embeddings of P to T 1 . Pattern P has one more embedding to T 1 which is not shown in the figure. Among the embeddings shown on the figure, the two on the left are isomorphisms. When embeddings are used, the mined patterns are called embedded [42,43]. In contrast to an isomorphism, an embedding can associate two adjacent nodes in the pattern to non-adjacent nodes on a path in the data tree.
The set of frequent induced patterns whose edges are seen as descendant edges is a subset of the set of frequent embedded patterns on the same tree T . In this paper, the mined patterns are embedded patterns. Support. When the dataset is a set of small trees, a natural way to define the support (frequency) of a pattern is to let it be equal to the number of trees that contain the pattern (called in the literature document frequency). However, document frequency is meaningless in the framework of a dataset which is a single large tree, as there is only one document. Therefore, a new definition for pattern support is needed for the setting of a single large tree. A desirable property for the support is the antimonotonicity property [43]. The antimonotonicity property is fundamental for efficiently enumerating patterns in the mining process.
In this framework, a natural candidate for the definition of pattern support is the number of occurrences (that is, embeddings) of the pattern in the dataset (occurrence frequency). Unforunately, occurrence frequency does not enjoy the antimonotonicity property. As we want to take advantage of the benefits of antimonotonicity, we adopt root frequency for embedded tree patterns: It can be shown [31] that root frequency has the antimonotonicity property.

Embedded Subpatterns
Usually, the mining process on a large data tree results in a large number of embedded tree patterns. It is therefore desirable to devise a concise and nonredundant representation for frequent embedded tree patterns. To this end, we introduce later the concepts of closed and maximal frequent embedded tree pattern. Closed and maximal tree patterns have been introduced before albeit in the context of induced tree patterns [6]. To define closed tree patterns we need the concept of subpattern. In the case of induced patterns, isomorphic subpatterns are employed: a pattern P ′ is an isomorphic subpattern of a pattern P iff there is an isomorphism from P ′ to P . This means that P ′ is a subtree of P . In other words, P ′ can be obtained from P by removing, in sequence, zero or more dangling edges (that is, edges incident to a leaf or root node) from P . We write P ′ ⊑ i P to indicate that P ′ is an isomorphic subpattern of P . Consider, for instance, the patterns shown in Figure 4. As one can see, P 1 ⊑ i P 2 ⊑ i P 3 ⊑ i P 4 , while P 5 ⊑ i P 4 , P 6 ⊑ i P 4 and P 6 ⊑ i P 5 . In particular, a root isomorphic subpattern is a special type of isomorphic subpattern: a pattern P ′ is a root isomorphic subpattern of a pattern P if and only if there is an isomorphism from P ′ to P which maps the root of P ′ to the root of P . For example, the pattern P 2 of Figure 4 is a root isomorphic subpattern of P 3 , while P 1 is an isomorphic subpattern but not root isomorphic subpattern of P 2 . However, the concept of isomorphic subpattern is not sufficient for embedded patterns since it cannot account for descendant relationships between nodes. We therefore generalize the concept of subpattern by introducing the concept of embedded subpattern to account for embedded patterns.
Definition 2.2 (Embedded subpattern) A pattern P ′ is an embedded subpattern of a pattern P (and P is an embedded superpattern of P ′ ) iff there is an embedding from P ′ to P . We write P ′ ⊑ e P to indicate that P ′ is an embedded subpattern of P , .
Consider again the patterns of Figure 4. One can see that P 1 ⊑ e P 2 ⊑ e P 3 ⊑ e P 4 and also that P 6 ⊑ e P 5 ⊑ e P 4 . Besides removing dangling edges, as is the case with isomorphic subpatterns, an embedded subpattern of a pattern P , can be obtained from P by replacing paths in P by edges. For instance, P 6 which is an embedded subpattern of P 4 , can be obtained from P 4 by replacing the paths from A to C and from A to D by the edges A/C and A/D, respectively.
Embedded subpatterns are related to isomorphic subpatterns the way the next proposition shows.
Indeed, if P ′ ⊑ i P , there is an isomorphism from P ′ to P . Therefore, there is an embedding from P ′ to P , i.e., P ′ ⊑ e P . As we can see in Figure 4, all the induced subpatterns are also embedded subpatterns. There are also examples in the figure of a pattern which is an embedded subpattern of another pattern but not an isomorphic subpattern. For instance, P 5 ⊑ e P 4 and P 5 ⊑ i P 4 .

Maximal and Closed Embedded Patterns and Problem Definition
Frequent induced patterns over multiple trees with document support are summarized using closed and maximal (induced) patterns. We want to introduce analogous concepts for embedded frequent patterns over a single tree with root support.
In the context of induced patterns over multiple trees with document support, a closed pattern is a frequent pattern such that no proper isomorphic superpattern has the same support. Note that an isomorphic superpattern of a pattern cannot have higher document support than the pattern itself. As a consequence, an induced pattern P is closed iff there is a proper superpattern P ′ which has an isomorphism i ′ to T whenever P has an isomorphism i to T such that i ′ is an extension of i. In the context of embedded patterns we use the following definition for closed patterns: Definition 2.3 (Closed pattern) Given a data tree T , an embedded frequent pattern P is closed iff there is no proper embedded superpattern P ′ satisfying the following property: for every embedding e of P to T there is also an embedding e ′ of P ′ to T such that e(root(P )) = e ′ (m(root(P ))) for some embedding m of P to P ′ .
Consider, for instance, the patterns P 1 and P 2 and the data tree T depicted in Figure 5. Pattern P 1 is an embedded subpattern of P 2 as there is an embedding from P 1 to P 2 . In fact, there are two such embeddings, shown in Figure 5(a), which map the root A of P 1 to the nodes A 1 and A 2 of P 2 . Pattern P 1 has six embeddings to T which map the root of P 1 to node a 2 in T (one embedding), to a 3 (one embedding) and to a 1 (four embeddings). In Figure 5(b), the dashed lines show possible mappings of the nodes of P 1 and P 2 to T . Pattern P 2 has two embeddings to T which map the root of P 2 to a 1 . One can see that for every one of the six embeddings of P 1 to T , one of the two embeddings of P 2 is its extension. For instance, for the embedding e of P 1 to T (e(A) = a 1 , e(B) = b 1 , e(C) = c 1 ), the embedding e ′ of P 2 to T (e ′ (A 1 ) = a 1 , e ′ (A 2 ) = a 1 , e ′ (B) = b 1 , e ′ (C) = c 1 ) is an extension of e based on the embedding m(A) = A 1 , m(B) = B, and m(C) = C of P 1 to P 2 . Therefore, P 1 is not closed, and P 2 or another superpattern which will turn out to be closed should be returned to the user instead. One can see that, in general, if a pattern P has an embedding to a pattern P ′ which maps the root of P to the root of P ′ , P is not closed.
Note that it would not be appropriate to define closed patterns in a simpler way based on root support (as this is done with induced patterns and document support). For instance, consider the data tree T and the patterns P 1 and P 2 of Figure 5. Assume that the support threshold is 1. As mentioned above, P 1 ⊑ e P 2 . The root support of P 1 on T is 3 while that of P 2 is 1. Therefore, if pattern closedness is decided based on root support, the presence of the embedded superpattern P 2 does not allow us to deduce, as Definition 5.1 postulates, that P 1 is not closed. In fact, it can be shown that, based on root support, P 1 is closed with support threshold 3, which counters our intuition.
We provide next a proposition which characterizes closed embedded patterns. Let L root (P 1 ) denote the set of the images of the root of pattern P 1 under all embeddings of P 1 to a data tree T . Given two patterns P 1 and P 2 such that P 1 ⊑ e P 2 , let n 1 , . . . , n k be the nodes in P 2 which are images of the root of P 1 under all embeddings of P 1 to P 2 . Then, let L root (P 1 |P 2 ) denote the set of the images of nodes n 1 , . . . , n k under all embedding of P 2 to T . As an example, in Figure 5, The proof follows easily from the definitions. In the example of Figure 5, P 1 is not closed since for its proper embedded superpattern P 2 , L root ( Maximal patterns can be defined without referring explicitly to the embeddings to the data tree (only their number matters):

Definition 2.4 (Maximal pattern) Given a data tree, an embedded frequent pattern is maximal if and only if there is no proper embedded superpattern which is also frequent.
Clearly, every maximal pattern is also closed. The opposite is not necessarily true. That is, the set of closed patterns is a superset of the set of maximal patterns for a given frequency threshold. Although maximal patterns provide a tighter summarization of the frequent embedded patterns than closed patterns, closed patterns are important as are they are more informative than maximal patterns about the frequent embedded pattern set they summarize.
Problem statement. Given a minimum support threshold and a large data tree T , find all the frequent unordered maximal and all the frequent unordered closed embedded patterns in T .
One of the reasons this problem is challenging is that, unlike the property of a pattern being frequent, pattern closedness (resp. maximality) does not have the antimonotonicity property: a superpattern of a non-closed (resp. non-maximal) pattern can be closed (resp. maximal).

Candidate Generation
In order to mine embedded patterns, our approach alternates between a step that generates candidate patterns and a step that computes the support of the patterns. The first step employs a process for systematically generating potentially frequent candidate patterns. For the second step, a novel technique is designed which computes the support of candidate patterns in an incremental way. We start by outlining below the candidate generation.
Canonical form. Because unordered patterns can have many different isomorphic representations, an efficient pattern mining process needs a method for avoiding the superfluous generation of isomorphic pattern representations and the superfluous isomorphism checking between pattern representations.
Several mining algorithms exploit the notion of tree canonical form which is a unique ordered representation of an unordered pattern and can be used as a representative of this pattern. Here we use a canonical from similar to the one adopted by [42] for tree patterns. A variety of alternative canonical tree representations is studied in [8].
Equivalence classes. For the generation of candidate patterns we follow the equivalence class-based pattern technique presented in [43,42]. We briefly outline next this technique, in order to also introduce concepts and notation which are needed along the paper.
The nodes of a pattern P are encoded by their depth-first position in P . The depth-first position of a node is the number assigned to the node in its first encounter during a depth first traversal of the pattern tree which sequentially assigns numbers starting with zero. The rightmost leaf of P is the node with the largest depth-first position and is denoted as rml. The rightmost path of P is the path from the root of P to the node rml. The immediate prefix of P is the sub-pattern of P obtained by removing the node rml from P . A prefix of P is the sub-pattern of P obtained by a series of deletions of the node rml .
We call k-pattern a pattern with k nodes. The equivalence class of a (k-1)pattern P (denoted as [P ]) is the set of all frequent k-patterns whose immediate prefix is P . The k-pattern constructed by adding a node labeled by x to the node at position i in P as the rightmost leaf node of [P ] is denoted by P i x . Let the term k-pattern refer to a pattern of size k. Given a (k-1)-pattern P (k ≥ 1), its equivalence class is the set of all frequent k-patterns which have P as immediate prefix. We write P i x to denote a k-pattern in [P ] formed by adding a child node labeled by x to the node with position i in P as its rightmost leaf node.
Expansion of patterns. The successor equivalence classes of an equivalence class [P ] are constructed by expanding the patterns in [P ]. This expansion works as follows: each pattern P i x ∈ [P ] is joined with any other pattern P j y ∈ [P ], including itself (self expansion). The result is the equivalence class [P i x ]. Two types of expansions are used: child expansion, implemented by a join operation, denoted P i x ⊗ c P j y (child join), and cousin expansion, implemented by a join operation,  denoted P i x ⊗ s P j y (cousin join). Formally: x since the numbering of nodes starts from 0.
The two outcome patterns Q k−1 y and Q j y are respectively called child and cousin expansions of P i x by P j y . Joining P i x with all elements P j y of [P ] produces all possible k-patterns in class [P i x ]. The patterns P i x and P j y are called, respectively, the left-parent and right-parent of a join outcome, respectively. Notice that each join outcome has its left-parent as its immediate prefix, and its righmost leaf is the rightmost leaf of its right-parent. Fig. 6 shows an example of an equivalence class expansion. The depth-first position of each node is shown by the node in the figure.
An example of the equivalence class-based pattern expansion is given in Fig. 6. The number associated with each pattern node in the figure is the depth-first position of that node. The left and right child rectangles surround, respectively, the patterns of the equivalence classes of the patterns A//B and A//C (note that A//B denotes that node A is an ancestor of node B).
Pattern search tree. Starting with patterns of size k=1, we can iteratively apply the equivalence class expansion to produce larger patterns. The construction of a pattern from another pattern defines a partial order, ≺, on patterns. This partial order is characterized by the prefix containment relationship, that is, P ≺ Q iff P is a prefix of Q. It is represented as a pattern search tree, in which node Q is descendant of P iff P ≺ Q. All the children of a given node P belong to its equivalence class [P ], since they all have the same immediate prefix P . Patterns in the search tree are organized in layers, where the 0th layer is the root denoting an empty pattern, and the kth layer consists of patterns with k nodes. Fig. 6(b) shows a fragment of an example pattern search tree for the patterns of Fig. 6(a).
The internal nodes of the search tree represent frequent patterns in canonical form. The execution of the pattern mining algorithm follows the growth a pattern search tree from the root. One-node frequent patterns are used as the initial pattern seeds. To augment a node P i x ∈ [P ], we require that P i x is frequent and in canonical form. Such a pattern P i x can only be expanded using patterns from [P ]. To guarantee that all the children of P i x in the tree will be generated, [P ] comprises all the possible frequent expansion outcomes of P (including non-canonical). Since infrequent or non-canonical patterns are not further grown, they correspond to leaf nodes.

Support Computation
From homomorphic occurrences to embedded ocurrences. We call embedded occurrence or simply occurrence of a pattern P on a data tree T a tuple indexed by the nodes of P whose values are the images of the corresponding nodes in P under an embedding of P to T . The occurrence relation OC(P ) of P on T is the relation containing the occurrences of P under all possible embeddings of P to T . If X is a node in P , the occurrence list L X of X on T is the projection of relation OC(P ) on attribute X sorted in the preorder appearance of the nodes in T . The occurrence list set OL(P ) of P on T is the set of all the occurrence lists of the nodes of P on T ; that is, OL(P ) = {L X | X ∈ nodes(P )}. The concepts of homomorphic occurrence, homomorphic occurrence relation OC h (P ), homomorphic occurrence list, and homomorhic occurrence list set OL h (P ) are defined analogously.
As mentioned above, in order to compute the support of a pattern P on a data tree T , we need to compute the size of the embedded occurrence list L R of the root R of P on T . A straightforward method for computing L R consists of first computing OC(P ), and then projecting OC(P ) on column R to get L R . A majority of existing tree mining algorithms [1,2,23,6,42,43,12,26,28,25,10,16] explicitly compute and store OC(P ). Unfortunately, the problem of finding an unordered embedding of P to T is NP-Complete [18]. On the other hand, finding a homomorphism from P to T can be done in PTIME [21].
Based on the above observation, we design a construction-pruning approach which first constructs OC h (P ) and then, prunes non-embedded occurrences to get OC(P ) (as mentioned above an embedding is a special case of homomorphisms). For the first step (the homomorphic occurrence construction) we employ a holistic twig-join algorithm. The second step (the non-embedded occurrence filtering) is implemented by checking whether two sibling nodes of P are mapped to nodes on the same path in T .
Holistic Twig-join Algorithms for computing homomorphic occurrences. Holistic twig-join algorithms (e.g., T wigStack [4]) are the state of the art algorithms for computing all the homomorphic occurrences of tree-patterns on tree data [4,5,13,20,3]. These algorithms were initially developed for computing tree-pattern queries over trees. They can provably compute all the homomorphic occurrences in time linear on the size of the input (the data tree) and the output (set of homomorphic occurrences) [4].
Filtering out non-embedded occurrences. Given a homomorphic occurrence occ checking whether it is also an embedded one is performed by traversing, in post order, the nodes of P ; if Y 1 , . . . , Y m are the child nodes of a node X under consideration we check if for no Y i and Y j , i = j, occ.Y i and occ.Y j are on one path (or coincide). As mentioned in Section 2.1 this constraint is termed sibling constraint. Clearly, we can deduce that occurrence occ is embedded if the sibling constraint is met. We can check whether two nodes are on one path in a tree T efficiently: each node in T is mapped to its positional representation which is a (begin, end, level) triple. This regional encoding allows for checking efficiently the existence of an descendant-ancestor relationship between two nodes: for two nodes n 1 and n 2 , n 2 is a descendant of n 1 iff n 2 .begin > n 1 .begin, and n 1 .end > n 2 .end.
Encoding pattern occurrences as occurrence list sets. For computing the pattern support we adopt an incremental technique which uses the materialized embedded occurrences of its parent patterns. We use an original materialization technique for the embedded occurrences of patterns which are processed earlier: we store the embedded occurrence lists of the nodes of the pattern instead of storing the embedded occurrence relation. The space efficiency of the method lies on the fact that the occurrence lists can encode in linear space in the number of pattern occurrences which is exponential on the number of pattern nodes [4]. In contrast, the state-ofthe-art embedded pattern mining techniques [43,42] record information about all the embedded occurrences of the processed patterns in the data tree.
Bitmap representation of occurrence lists. The pattern occurrence lists are stored as bitmaps. This choice allows for a big reduction in the storage cost. In addition, using bitmaps also allows for important CPU and I/O cost reductions. Indeed, occurrence list intersection of the nodes of a pattern can be realized as a two-step bitwise operation: the first step consists in bitwise ANDing the bitmaps of the occurrence lists of the pattern nodes. The second step materializes the intended occurrence list by fetching in memory, from the corresponding inverted list, the nodes indicated by the resulting bitmap. The benefit of the use of bitmaps in time consumption is twofold: certainly bitwise ANDing is cheaper than the intersection of the possibly long corresponding occurrence lists. Further, retrieving in memory only the nodes indicated by the result bitmap has less I/O cots than the retrieval of the entire-possibly very large-operand occurrence lists. The latter retrieval is necessary for applying the intersection operation in the traditional way. We used bitmaps for the storage and processing of occurrence lists initially in [37,38,34,33] in the context of evaluating queries using tree-pattern materialized views.

An Eager Closedness Checking Algorithm
We provide in this section an algorithm which produces embedded frequent patterns and eagerly filters out non-closed ones. The pattern support is computed in this algorithm by extending a procedure presented in [31,36] for computing frequent embedded patterns. The algorithm involves an efficient local closedness checking technique which is integrated in the mining process so that non-closed patterns can be eliminated early on.

Closedness Checking
Pattern-subpattern relationship checking. In order to determine if a given pattern P is closed, we first need to check if P is a proper subpattern of some other pattern Q, and find all the nodes in Q which are images of the root of P under an embedding from P to Q (Proposition 2.2). For this, we can utilize the unordered tree inclusion algorithm described in [18]. Provided two unordered trees P and Q, this algorithm finds all the nodes v in Q, such that there exists a root-preserving embedding from P to the subtree of Q rooted at node v. The time complexity of the algorithm is O(|P |× P f × 2 2P f × |Q|), with P f being the max outdegree of the nodes in P . However, in the experiments, we found that this algorithm runs very slowly for patterns with large fan-out. We therefore use a procedure we presented in [31] which computes embeddings of a pattern to a tree and this turns out to be faster.
Once we have obtained the root images r 1 , . . . r k of P on Q, the computation of L(P |Q) is straightforward, as it is the union of L r i (Q)s, i ∈ [1, . . . , k]. Observe that, since the occurrence lists are represented as bitmaps, a bitwise OR operation will allow this union operation to be performed efficiently. Pattern closedness checking. A straightforward method for determining whether a frequent pattern P is closed (or maximal) is to employ a postprocessing filtering technique. This technique starts by finding and storing in a set S all frequent embedded patterns, and then performs a pairwise checking of patterns in S to eliminate those patterns that are not closed (or maximal). Note that the problem of checking if one pattern is an embedded subpattern of another is NP-Complete [18]. This technique requires storing all the frequent patterns and doing O(|S| 2 ) such checks. Clearly, this technique is not efficient since the number of closed and maximal patterns can be exponentially smaller than the number of frequent patterns.
An alternative way is to check each pattern P for closedness as soon as it is discovered to be frequent. In this case one can enumerate all the possible embedded superpatterns having one more node than P , and then check whether there is a frequent superpattern P ′ s.t. L root (P ) = L root (P |P ′ ). For maximality, we just need to check if the superpattern P ′ is frequent. Although this method does not need to store any discovered patterns, it has to enumerate a large number of patterns, and it is possible that a big number of superpatterns might be repeatedly generated and checked throughout the mining process.
Therefore, we develop a method which does not have the drawbacks of the techniques above. During the frequent pattern mining process, this method identifies a subset of frequent patterns which is a superset of closed patterns, and are called locally closed patterns. A frequent pattern P is locally closed if its root occurrence list is not equal to that of any pattern which can be obtained by joining P (as a left or right operand) with a pattern from its class. A pattern P is locally maximal if there are no canonical patterns in the class [P ]. Obviously, a pattern which is not locally closed (or locally maximal) is not closed (or maximal). Consequently, we can find the "globally" closed patterns, by checking only locally closed patterns for closedness. Maximal patterns can be found similarly. This way, the search is narrowed to only those potentially closed (or maximal) patterns. Procedure M ineEmbP atterns of Fig. 7 implements this method opportunistically. Pruning non-closed patterns eagerly. In order to prune non-closed patterns, we maintain a set C of all the patterns that are found to be closed w.r.t. frequent patterns discovered so far. Set C is initially empty. When all the possible expansions of a current pattern P have been processed and P has been found to be locally closed, it is compared with patterns in C. It is added to C, if there is no pattern Q in C which is a proper superpattern of P and L root (P ) = L root (P |Q). At the same time, patterns Q in C that are sub-patterns of P and satisfy the property L root (Q) = L root (Q|P ) are removed from C. During the pattern comparison process, any pattern that is found to be a subpattern of another pattern is characterized as non-maximal. Procedure CheckClosedM axSubpattern of Fig. 7 implements this process.

The Closed Embedded Tree Pattern Mining Algorithm closedEmbTMeager
We describe below the closed embedded tree pattern mining algorithm which checks for closedness eagerly. The algorithms is called closedEmbTM-eager and is shown in Fig. 7. Algorithm closedEmbTM-eager first generates frequent 1-patterns (set F 1 ) and 2-patterns (set F 2 ). The equivalence class-based expansion technique (Section 3.1) is used to recursively constructs larger patterns by expanding each 2-pattern ∈ F 2 in a depth-first manner. While generating the patterns, closedEmb-TM-eager uses the eager pattern closedness checking method described in Sec. 4.1 for reducing the pattern search space. The outer procedure calls M ineEmbP atterns on each frequent 2-pattern (lines [4][5]. M ineEmbP atterns confirms that a pattern P i x is in canonical form before expanding it (line 2). Subsequently, pattern P i x is expanded through a join with each pattern P j y ∈ [P ] (if this is possible) and the occurrence list set of every join result is computed by evoking function computeEmbOL (lines 5-7). Function computeEmbOL computes the embedded occurrence lists for all the pattern nodes. It is an variation of the function computeEmbOL introduced in [31,36] Input: minsup and set L of inverted lists of tree T . Output: set C of frequent closed and set M of frequent maximal embedded k-patterns in T (k > 1). if (P i x is in canonical form) then 3.

5.
for (each P j y ∈ [P ]) do 6. for (each expansion outcome Q of P i x ⊗ P j y ) do 7.
add Q to [P i x ]; 10. let L ri ,L rj , L rQ be the emb. root occur. lists of P i x , P j y and Q, respectively; 11. if (L rQ = L ri ) then 12.
P.isClosed := false; 10. if (P.isClosed) then 11. add P to C; for computing the pattern support extended so that it computes the embedded occurrence lists of all the nodes of the pattern and not only the embedded occurrence list of the root of the pattern. Patterns that are discovered to be frequent are included in the class [P i x ] under construction (line 9). Also, P i x and P j y can possibly be marked as non-locally closed (lines 12 and 14). After all patterns P j y have been joined with P i x , the class [P i x ] comprises all frequent patterns which share the common immediate prefix P i x . At this time, if P i x has not been marked as non-locally closed, M ineEmbP atterns calls procedure CheckCloM axSubpattern on P i x to prune non-closed patterns (lines [15][16]. Finally, M ineEmbP atterns is recursively called on [P i x ] to extract bigger frequent patterns which have a common prefix P i x (line 17). This process iterates recursively till all frequent patterns are produced.

A Search Space Pruning Algorithm
Despite the early pattern closedness checking, Algorithm closedEmbTM-eager may generate numerous intermediate patterns which do not expand to become closed patterns. This motivates the need for developing an algorithm which exploits techniques for further pruning the generation of such non-promising intermediate patterns. We start by introducing these search space pruning techniques.

Pattern Search Space Pruning Techniques
Ordering the search space tree. In order to introduce our search space pruning rules, we impose an order on the search space tree (Section 3.1). We first define a linear order ≤ on tree pattern representations. Let there be a linear order ≤ on the labels of nodes in the input data tree. Let P 1 and P 2 be two tree patterns representations whose roots are r 1 and r 2 , respectively, and let c r 1 1 , . . . , c r 1 m and c r 2 1 , . . . , c r 2 n be, respectively, the lists of the children of r 1 and r 2 . If x is a node in a tree, st(x) denotes the subtree (tree pattern representation) rooted at node x. Then, P 1 ≤ P 2 iff: • lb(r 1 ) < lb(r 2 ), or • lb(r 1 ) = lb(r 2 ), and either: (a) n ≤ m and st(c r 1 i ) = st(c r 2 i ), ∀i ∈ [1, n], i.e., P 2 is equal to, or a prefix of P 1 ,or (b) ∃j ∈ [1, min(m, n)] s.t. st(c r 1 i ) = st(c r 2 i ), ∀i, i < j, and st(c r 1 j ) < st(c r 2 j ).
A pattern search tree becomes ordered when we enforce the linear order ≤ on sibling patterns of the tree. A pattern is created before its right sibling patterns in the ordered search space tree.
Our pruning rule is based on the observation that if it is known that a generated pattern and all (or some) of its descendant patterns in the pattern search tree are not closed, then these descendants need not be generated at all (they can be pruned from the pattern search tree). Our pruning rules are expressed using the concepts of child and cousin surrogates introduced below. Child and cousin surrogates. We start by defining child surrogates. We first define the concept of occurrence equivalent patterns. Let P be an embedded subpattern of a pattern P ′ . If e and e ′ are embeddings of P and P ′ to a data tree T , respectively, e ′ is an extension of e if there exists an embedding m of P into P ′ s.t. e(X) = e ′ (m(X)), for every node X in P .
Definition 5.1 (Pattern occurrence equivalence) Let P be an embedded subpattern of P ′ , and let M (P, P ′ ) represent the set of possible embeddings from P to P ′ . Patterns P and P ′ are occurrence equivalent iff for every embedded occurrence e of P to T there exists an embedded occurrence of P ′ to T which is an extension to e for some m ∈ M (P, P ′ ). We use the notation P ≡ P ′ for occurrence equivalent patterns P and P ′ .
The concept of occurrence equivalence was first introduced in [41] for mining induced subgraphs, and was also later used in [6], with a different name, for mining induced subtrees. Our definition generalizes these definitions, as it considers patterns related through embeddings not merely isomorphisms.
Since non-canonical patterns are not further expanded, we focus on finding canonical patterns. We call an expansion "canonical" if the expansion outcome is a canonical pattern. In the following discussion, except when stating differently, we assume canonical expansions.
Consider the example of Fig. 8. In this figure, focus on the data tree T and the frequent patterns (assuming minimum support 2) P 0 = A, P 1 = A//B, P 2 = A//C, and P 3 = A//D shown in Fig. 8(a). One can see that the equivalence class [A] of A is {A//B, A//C, A//D}. Let's now look at a property of patterns P 1 = A//B and P 2 = A//C in [A]. Observe that in every embedding of pattern P 2 = A//C to the T , B is an ancestor of C below node A in the data tree. In other words, every time P 2 has an embedding to T , pattern Q 1 = P 1 ⊗ c P 2 = A//B//C also has an embedding to T which coincides with P 2 on their common part (nodes A and C). This means that P 2 ≡ Q 1 . Fig. 8(b) shows the occurrence sets OC(P 2 ) and OC(Q 1 ) of P 1 and Q 1 , respectively.
Further, let's see another property of patterns P 1 and P 2 in [A]. Consider pattern Fig. 8(c). It is, P 2 < P 3 . Observe that in every embedding of the pattern P 2 ⊗ c P 3 (or P 2 ⊗ s P 3 ) to T , node B is an ancestor of node C below the common part of P 2 = A//C and P 3 = A//D (which is node A) in the data tree. In other words, every time P 2 ⊗ c P 3 (resp. P 2 ⊗ s P 3 ) has an embedding to T , pattern Q 1 ⊗ c Q 2 (resp. Q 2 ⊗ s Q 3 ) also has an embedding to T which coincides with P 2 ⊗ c P 3 (resp. P 2 ⊗ s P 3 ) on their common part (nodes A, C and D). That is, ). When this property holds for patterns P 1 and P 2 not only in relation to pattern P 3 but also in relation to every pattern P z (P 2 ≤ P z ) in the class [A] in which P 1 and P 2 belong, we say that P 1 = A//B is a surrogate pattern of P 2 = A//C. A formal definition follows. Definition 5.2 Consider two distinct patterns P i x and P i y in the class [P ], such that P i x < P i y , and let Q be the child expansion of P x with P y (Q = P i x ⊗ c P i y ). We say that P i x is a child surrogate of P i y , if: (a) P i y ≡ Q, and Example 5.1 As mentioned above, Fig. 8 shows an example of a child surrogate: P 1 is a child surrogate of P 2 . Fig. 9 shows a non-example of a child surrogate: P 1 is not a child surrogate of P 2 . Indeed, as shown in the figure even though the condition (a) of Definition 5.2 is satisfied, there is pattern

. That is, condition (b) of Definition 5.2 is violated.
If P i x is a child surrogate of P i y then, clearly, P i y is not closed and the same is true for any canonical expansion (child or cousin) of P i y . We will show later that every node in the pattern tree rooted at P i y is also not closed and therefore, these nodes need not be generated.
Analogously to child surrogates, we define cousin surrogates.

Definition 5.3
Consider two distinct patterns P i x and P j y , i ≥ j, in the class [P ], such that P i x < P j y , and let Q be the cousin expansion outcome of P i x with P j y (Q = P i x ⊗ s P j y ). We say that P i x is a cousin surrogate of P j y , if: (a) P j y ≡ Q, and (b) for any P k z ∈ [P ], such that P j y ≤ P k z , P j y ⊗ s P k z ≡ (P i x ⊗ s P j y )⊗ s (P i x ⊗ s P k z ).
Example 5.2 Consider the data tree T of Fig. 10(a) and the frequent patterns (assuming minimum support 2) P = A, P 1 = A//B, P 2 = A//C, P 3 = A//D, P 4 = A//E, and P 5 = A//F . The equivalence class [A] of A is {P 1 , P 2 , P 3 , P 4 , P 5 }. Pattern P 1 is a cousin surrogate of P 4 since, as shown in Fig. 10(b), both conditions of Definition 5.3 are satisfied: (1) P 4 ≡ Q 2 (= P 1 ⊗ P 4 ), and (2) for P 5 ∈ [A] (P 5 is the only pattern in the class [A] which follows P 4 ), P 4 ⊗ s P 5 ≡ (P 1 ⊗ s P 4 ) ⊗ s (P 1 ⊗ s P 5 ). Note that P 4 ⊗ c P 5 does not have any occurrences in the data tree T . In contrast, pattern P 1 is not a cousin surrogate of P 2 . Indeed, as shown in Fig. 10(c), even though P 2 ≡ Q 3 (= P 1 ⊗ P 2 ), for the pattern P 3 in the class

. That is, condition (2) of Definition 5.3 is not satisfied.
Under certain circumstances, checking for cousin surrogates can be simplified as the next proposition shows. Proposition 5.1 Consider two distinct patterns P i x and P j y , i ≥ j, in the class [P ], such that P i x < P j y . If P j y ≡ P i x ⊗ s P j y , and for any P k z ∈ [P ] such that P j y < P k z , we have i > k, then P i x is a cousin surrogate of P j y .

Example 5.3
Consider the data tree T of Fig. 11(a) and the frequent patterns (assuming minimum support 2) P, P 1 , P 2 , and P 3 . The equivalence class [P ] of P = A//B is {P 1 , P 2 , P 3 }. Patterns P 1 and P 2 satisfy condition (a) of Definition 5.3 as P 2 ≡ P 1 ⊗ s P 2 . There is only one pattern (pattern P 3 ) in [P ] which follows pattern P 1 (P 1 < P 3 ). Observe that the position of the rightmost leaf of P 3 (position 0) is inferior to the position of the rightmost leaf of P 1 (position 1). In this case, we can conclude that condition 2 of definition 5.3 is satified without checking (and that P 1 is a cousin surrogate of P 2 ). Indeed, in every occurrence of P 2 ⊗ s P 3 , D occurs under B in T (P 2 ⊗ c P 3 does not have any occurrence in T ) .
Pattern search tree pruning. We exploit the concepts of child and cousin surrogates to design a technique which allows pruning branches (subtrees) of patterns from the pattern search tree. We start by providing a lemma.

Lemma 5.1 If a pattern has a child or a cousin surrogate, then neither itself nor anyone of its (child or cousin) expansion can be closed.
Based on lemma 5.1, we design a pruning rule: Prunning Rule: If a pattern has a child or cousin surrogate, then none of its descendants in the pattern search tree needs to be generated.
The correctness of the prunning rule is shown by the next proposition.  Figure 11: The rightmost leaf position of P 1 is larger than that of P 3 : P 1 is a cousin surrogate of P 2 .

Proposition 5.2 If a pattern has a child or a cousin surrogate, then neither itself nor anyone of its descendants in the pattern search tree can be closed (or maximal).
For instance, in the example of Fig. 8, pattern P 1 is shown to be a child surrogate of pattern P 2 . Therefore, P 2 does not need to be expanded: none of its descendants will be closed (or maximal). The same holds for pattern P 4 in the example of Fig. 10 since it was shown there that pattern P 1 is a cousin surrogate of P 4 .

The Closed and Maximal Embedded Pattern Mining Algorithm closedEmbTM-prune
We now present closedEmbTM-prune, an efficient algorithm which allows extracting all closed and maximal embedded frequent patterns. The pseudo-code for closedEmbTM-prune for patterns with at least two nodes appears in Fig. 12. The main computation is performed by Procedure MineClosedMaxEmbPatterns called on frequent 2-patterns (Line 3-4). While the high level structure of MineClosed-MaxEmbPatterns is similar to Procedure M ineEmbP atterns (Fig. 7), MineClosed-MaxEmbPatterns comprises several important extensions which are described below. Class element ordering. As mentioned in Section 5.1, in order to facilitate pattern pruning, we impose a tree order among sibling nodes in the pattern search tree. To implement the ordering efficiently, we maintain the elements P i x in every class primarily ordered on the position i (in descending order) and secondarily by the node label x (in ascending order). It is not difficult to see that this class element ordering coincides with the tree order defined in Section 3.1. Given the sorted element list of a class, for each pair of elements, the equivalence class expansion process first tries to apply child expansion (Lines 7-8), and then cousin expansion (Lines 10-11). The class under expansion is associated with two lists for storing the outcomes of child and cousin expansions. The expansion outcomes are added into Input: frequency threshold minsup and inverted lists L of tree T . Output: set C of the closed embedded patterns, set M of the maximal embedded patterns in T which have at least two nodes. if (P i x is non-canonical or a cousin surrogate of P i x has been identified using Prop. 5.1) then 3. continue;

5.
for (each P j z ∈ [P ] in ascending order) do 6.
if (i = j and P i x ≤ P j z ) then 9. for (every P j y ∈ [P ] s.t. P i x < P j y ≤ P j z ) do 10. if (P i x is in the child candidate list of P j y , and P j z violates the conditions of Prop. 5.3) then 11. remove P i x from the child candidate list of P j y ; 12. if (P i x is in the cousin candidate list of P j y , and P j z violates the conditions of Prop. 5.4) then 13. remove P i x from the cousin candidate list of P j y ; 14. if (P i x .isLocallyClosed is true) then

15.
CheckClosedM axSubpattern(C, P ); 16. if (no pattern in the candidate child and cousin surrogate lists of P i x is a surrogate of P i x ) then 17.

M ineClosedM axEmbP atterns([P
if (Q is in canonical form) then

5.
F indSurrogateCandidate(P i x , P j y , Q); Figure 12: Closed and maximal embedded pattern mining Algorithm closedEmpTM-prune. their corresponding lists in the order they are generated. After all the expansion operations for the current class are finished, the cousin expansion list is appended to the child expansion list. This expansion process guarantees that the candidate generation phase returns an ordered set of patterns (no explicit ordering is needed). Pattern expansion pruning. The pruning rule presented above is applied throughout the pattern mining process. The pruning rule requires identifying child/cousin surrogates of patterns during the mining process. In order to determine whether a given pattern P has a child or cousin surrogate, we first need to identify a pattern preceding 1 P which satisfies condition (a) in the definition 5.2 or 5.3. Then we expand P with each of the patterns that follow P in the class ordering, in order to check if condition (b) of definitions 5.2 and 5.3 is satisfied. Proposition 5.1 allows identifying a cousin surrogate of P without exhaustively expanding P.
Improving the pruning process. Next, we introduce two propositions which can help avoiding part of the computation while determining child and cousin surrogates. Let Π P i x (OC(P i x ⊗ c P i y )) denote the projection of the embedded occurrence set OC(P i x ⊗ c P i y ) on the attributes corresponding to the nodes of P i x .

Proposition 5.3
If P i x is a child surrogate of P i y then for any P i z ∈ [P ] such that P i y < P i z and Π P (P i y ) = Π P (P i z ), Going back to the example of Figure 9, we can see that the conditions of Proposition 5.3 are not satisfied when P i x = P 1 , P i y = P 2 and P i z = P 4 . Therefore, we can conclude that P 1 is not a child surrogate of P 2 without recurring to exhaustively checking the conditions of Definition 5.2.
x is a cousin surrogate of P i y , then for any P i z ∈ [P ] such that In the example of Fig. 10, the conditions of Proposition 5.4 are not satisfied when P i x = P 1 , P i y = P 2 and P i z = P 3 . Therefore, we can conclude that P 1 is not a child surrogate of P 2 avoiding the exhaustive checking of the conditions of Definition 5.3.
Algorithm description. We describe now in more detail how the pruning rule is integrated into the mining process. Let P i x be the pattern under consideration in class [P ]. Pattern P i x is not expanded if it is non-canonical or a cousin surrogate of it has been identified earlier using Proposition 5.1 (Lines 2-3 of MineClosedMaxEm-bPatterns). Otherwise, Procedure ComputeExpansion is invoked to compute the joins P i x ⊗ P k z of P i x with a patern P k z in [P ] (Lines 6-7). Procedure ComputeExpansion, in turn, calls computeEmbOL which computes the embedded occurrence lists of the join outcome. Let Q denote the outcome of P i x ⊗ P j z . If Q is frequent and canonical, CompExpansion goes on to check, via a call to FindSurrogateCandidate, shown in Figure 13, whether: (1) P i x and P j z are locally closed (Lines 2-5), and (2) P i x and P j z satisfy Condition (a) of the child/cousin surrogate definition (Line 6). To facilitate this checking, each pattern in an equivalence class is associated with two lists recording its child and cousin surrogate candidates (Lines 8 and Procedure F indSurrogateCandidate(P i x , P j y , Q) 1. let L ri ,L rj , L rQ be the embedded root occurrence lists of P i x , P j y and Q, respectively; add P i x to the cousin surrogate candidate list of P j y ; 9. if (i > j) then 10. mark P i x as a cousin surrogate of P j y ; 11. else if (Q = P i x ⊗ s P j y ) then 12. add P i x to the child surrogate candidate list of P j y ; Figure 13: Find candidate child and cousin surrogates.
12). Pattern P i x can be determined to be a cousin surrogate when the condition of Proposition 5.1 is satisfied (Lines 9-10). A child/cousin surrogate candidate added by FindSurrogateCandidate to a candidate list may be removed later, when a pattern in the same class disqualifies it (Lines 8-13 of MineClosedMaxEmbPatterns). The patterns in the class [P i x ] are expanded only when no candidate in the child and cousin surrogate candidate lists of P i x is indeed a surrogate of P i x (Lines 16-17 of Procedure M ineClosedM axEmbP atterns). Proof. Algorithm closedEmpTM-prune correctly identifies all the closed frequent embedded tree patterns since its search is based on a complete traversal of the pattern search tree. The only branches that are pruned are those that either do not have sufficient support or those that have a child or cousin surrogate (Proposition 5.2 establishes the correctness of the latter pruning). In addition, throughout the mining process, closedEmpTM-prune maintains a set C that stores all the locally closed patterns that are found to be closed w.r.t. frequent patterns discovered so far. A locally closed pattern P is inserted into C only if Procedure CheckClosedMaxSubpattern cannot find any embedded superpattern in C which violates the closedness of P . If P is inserted into C, all embedded subpatterns of P which Procedure CheckClosedMaxSubpattern identifies as non-closed are eliminated from C. The closedness checking process also identifies and marks non-maximal patterns in C. When the mining process terminates, C contains exactly all the closed patterns, while the non-marked patterns in C are the maximal patterns.

Experimental Evaluation
Algorithms in comparison. To evaluate our approach, we have designed different experiments. We implemented and compared our algorithms closedEmbTM-eager and closedEmbTM-prune. To the best of our knowledge, there is no previous algorithm for mining closed and maximal embedded patterns from data trees. Therefore, we compared the performance of our two algorithms with a baseline algorithm which first computes the embedded tree patterns and then filters out non-closed (or non-maximal) ones. We call this post-processing algorithm closedEmbTM-base. In order to compute frequent embedded patterns, closedEmbTM-base extends the algorithm embTM [31,36] which mines frequent embedded patterns from data trees so that it computes the occurrence lists not only of the root but also of the other nodes of a pattern. The pattern node occurrence lists are used in the post-processing phase for checking pattern closedness.
In order to contrast the performance of mining closed embedded patterns with mining frequent embedded pattrens, we also compare these three algorithms with sleuth [42], which is a state-of-the-art unordered embedded tree mining algorithm. The goal of this algorithm was to mine embedded patterns from small tree collections. In order to make the comparison meaningful, sleuth was slightly altered so that it mines patterns from a single large tree. This was achieved by having sleuth adopting root frequency instead of document frequency as the support of a pattern. The performance of sleuth is not affected by this adaptation. In fact, by design, all the embedded occurrences of a pattern under consideration in a data tree are computed by sleuth. Note that algorithm embTM was shown to outperform Sleuth [31,36] but we included also Sleuth in this comparison since embTM is employed in closedEmbTM-base.

Experimental Setting
We implemented our approach in Java. For the experiments we ran JVM 1.8 on a workstation having an Intel Xeon CPU 3565 @3.20 GHz processor. Datasets. For the experiments we employed three datasets with diverse structural features which are popular in pattern mining. The Table 2    comprises few recursive nodes (i.e., nodes which coexist on the same path with other nodes having the same label). The DBLP 3 dataset provides bibliographic information and is a real dataset. The dataset is bushy, flat and shallow. It comprises few regularly structured patterns. As XMark, it includes very few recursive elements.
The CSlogs 4 dataset is presented in [43] and comprises real data. It contains navigation trees of different users on the website of the RPI CS department. The dataset involves 13355 distinct web pages which are accessed in 59,691 trees (with an average tree size of 12.94). Pattern distribution. To get a better understanding of the characteristics of the datasests, we show the distribution of frequent, closed, and maximal embedded patterns on the three datasets in Figs though are different. The distribution of CSlogs is right-skewed. Many patterns in CSlogs are of small size. XMark has substantially larger frequent embedded patterns, and considerably more patterns than the other two datasets. The maximal patterns are contained in the closed patterns and both of them are contained in the set of frequent embedded patterns. We observe that, on XMark and DBLP, the closed patterns and maximal patterns are substantially less numerous than the frequent embedded patterns; on CSlogs, the number differences among the three pattern types are moderate. As we show below, the distribution of patterns affects the effectiveness of the closed pattern pruning rules.  Table 3 shows statistics for patterns generated and evaluated by closedEmbTM-prune and closedEmbTM-eager at the two smallest support levels tested on each dataset. The column #computed records the number of generated patterns whose support has been computed. Columns #lclosed and #lmax record the number of locally closed and locally maximal embedded patterns, respectively. Note that closedEmbTMbase computes the same set of frequent and candidate patterns as closedEmbTM-   eager, but it does not generate locally closed and maximal patterns. The following observations can be made.

Execution time and memory usage.
First of all, sleuth runs orders of magnitude slower than the three algorithms closedEmbTM-base, closedEmbTM-eager and closedEmbTM-prune. On DBLP, sleuth cannot complete the computation within 12   support level tested. In addition, the rate at which the execution time of the three algorithms increases as the support level decreases is slower compared to sleuth. The explanation for this big performance difference is not the fact that sleuth computes embedded patterns which are more numerous than closed patterns. Instead, it is the fact that our algorithms calculate the pattern support more efficiently. sleuth is forced to record all embedded occurrences of each considered pattern in the data, and join them. As a consequence, its performance suffers when mining dense data at low support levels. sleuth is also forced to keep in memory the occurrences of the considered patterns and this negatively affects memory consumption. Nevertheless, when the number of embedded occurrences at the corresponding support level is not large, sleuth does not consume too much memory and can complete the computation within a reasonable amount of time. Second, closedEmbTM-prune outperforms closedEmbTM-base and closedEmb-TM-eager on both XMark and DBLP by a great margin, with a speeding factor of up to 212 and 8 respectively. The large performance gap is due to the large number of candidate patterns pruned by closedEmbTM-prune on the two datasets. For instance, as shown in Table 3, on XMark at minsup = 600, the candidate patterns enumerated and the frequent patterns computed by closedEmbTM-prune are respectively 37 times and 49 times less than with closedEmbTM-eager (and closedEmbTM-base). Also, comparing to closedEmbTM-eager, closedEmbTMprune reduces the number of locally closed (resp. locally maximal) patterns that need to go through the closedness (resp. maximality) checking by a factor of 76 (resp. 87). On DBLP, the number of patterns checked and the number of frequent patterns computed by closedEmbTM-prune are also significantly smaller than with the other two methods.
The large gap in the number of generated patterns explains also the smaller memory usage by closedEmbTM-prune on both XMark and DBLP (Figs. 17(b) and 18(b)). The advantage of memory consumption by closedEmbTM-prune is more prominent on DBLP. The reason is that DBLP contains a large number of patterns having repeated siblings. Checking the sibling constraint is more costly for patterns with repeated siblings. closedEmbTM-prune is able to skip computing the support of many of those patterns. These results demonstrate the effectiveness of the pruning techniques used by closedEmbTM-prune, which allow skipping a large number of non-closed patterns from the pattern search space.  On CSlogs, closedEmbTM-prune runs slightly slower than closedEmbTM-eager until minsup reaches 400. After that, closedEmbTM-prune catches up and runs faster as minsup becomes smaller, with a speedup factor of 2 when minsup is 200. A similar trend can be observed on memory usage: closedEmbTM-prune consumes a bit more memory than closedEmbTM-eager when minsup exceeds 400; after that, its memory usage becomes similar to that of closedEmbTM-eager. This can be explained by the fact that finding the child and cousin surrogates for the pruning rules incur an overhead. When the benefit from the reduction on the number of patterns considered due to pruning exceeds the pruning overhead, closedEmbTMprune outperforms closedEmbTM-eager.
The time and memory performance of closedEmbTM-eager and closedEmbTMbase are in general very close. However, closedEmbTM-eager has a noticeable performance advantage over closedEmbTM-base once the support level becomes very small. Note that the frequent patterns generated by the two algorithms are exactly the same. By maintaining a set of locally-closed patterns, closedEmbTM-eager succesfully reduces the total number of pair-wise pattern containment checking to identify closed patterns. With closedEmbTM-base, the entire set of frequent patterns, whose size can be exponential in the size of the locally-closed pattern set, is checked for closedness. In general, when the frequent pattern set examined is not very large, the total time spent on pattern closedness checking is very small. For instance, on XMark, when the frequent patterns are less than 100k, the closedness checking time does not even represent 2.6% of the total execution time of closedEmbTM-base. However, this percentage jumps to 31.6% when minsup is 600 and the number of frequent patterns is around 430k. Also, at this point, the memory consumption of closedEmbTM-base exceeds that of closedEmbTM-eager by a factor of over 7.

Scalability Comparison
We studied the scalability of closedEmbTM-prune, closedEmbTM-eager and closedEmbTM-base as the size of the input data on XMark (which is a single large data tree) and CSlogs (which is a collection of small trees) increases. For the exper-  iments with XMark, 10 XMark trees were generated. The scaling factor parameter of XMark was set to 0.01, 0.02, . . . , 0.10 and the minsup was fixed at 1800. For the experiments with CSlogs, seven datasets of different sizes (ranging from 40k to 100k trees) were generated. The data trees were randomly selected from the original CSlogs dataset. The minsup was fixed at 400. The results on XMark (Fig. 20) show that closedEmbTM-base and closedEmbTMeager have similar time performance and memory usage, and closedEmbTM-prune has the best time performance. The execution time of closedEmbTM-prune progresses smoothly as the input data size increases, whereas the execution time of the other two algorithms increases sharply. Overall, closedEmbTM-prune has a speedup factor up to 125 over the other two. Its memory consumption is also smaller than the other two in all the testing cases.
The results on CSlogs (Fig. 21) show that closedEmbTM-base and closedEmbTMeager have similar time performances, while closedEmbTM-prune runs noticeably faster than the other two when the dataset size reaches and goes above 70k. The three methods have overall similar memory performances.

Related Work
We review in this section related literature and comment on how it relates to our work. Because of its importance, the problem of extracting tree patterns from collections of small trees has attracted a lot of attention in recent years. Different algorithms have been proposed [1,27,2,39,7,23,11,6,42,43,12,26,28,25,10,16,31,36], but only a handful of them address the problem of mining unordered embedded patterns [27,11,42,31,36]. None of them introduces closed or maximal unordered embedded tree patterns or discusses pattern summarization.
There are some algorithms [39,6,24,28] which deal with extracting closed or maximal induced patterns. Recall that induced patterns are based on isomorphisms which, contrary to embeddings, cannot map pattern edges to paths in the data. Further, these algorithms are restricted to extracting patterns from collections of small trees as opposed to extracting patterns from a single large tree. We briefly review these approaches below.
CM T reeM iner [6] mines both closed and maximal frequent patterns from a set of small trees. This approach exploits a concept called blanket of a pattern which is the set of all its frequent immediate super patterns. The occurrences of a pattern under consideration are compared with those of its blanket pattern to determine whether it is closed or not. In order to reduce the search space, CM T ree-M iner employs heuristic and pruning techniques. Unlike previous algorithms, it precisely extracts maximal and closed patterns without previously producing all frequent patterns. Nevertheless, it is restricted on mining only induced patterns. Two mining algorithms for closed induced ordered patterns are described in [24]. These algorithms combine the pruning techniques of CM T reeM iner with two different pattern enumeration strategies.
P athJoin [39] operates on a collection of small trees and extracts maximal unordered induced patterns. P athJoin accepts only datasets where sibling nodes in the data tree cannot be labeled by the same label. It proceeds by initially discovering all the maximal frequent paths. Candidate frequent tree patterns are then found by joining the maximal frequent paths. These candidate patterns are then used to select maximal frequent patterns through a post-processing filtering phase. This method has a considerable performance penalty, in particular, when there are many false positive patterns.
DryadeP arent [28] also operates on collections of small trees and extracts closed induced patterns. It proceeds by first computing all closed frequent patterns of depth one which are called tiles. It then employs a hooking method which uses these tiles to construct closed frequent patterns. The authors observe that one parameter that dramatically affects the performance of previous algorithms is the outdegree of the tree patterns. Therefore, similar to P athJoin, it restricts the input data trees to those that do not have two sibling nodes with the same label. Even though this assumption certainly makes the problem easier, it also narrows the usability of the approach in real cases.
As we have explained in the introduction, the approaches above cannot be leveraged for mining closed and maximal embedded patterns from a large tree.
There has been only very limited contributions on mining tree patterns from a single tree or graph. They are restricted to [12,10,16] which focus on extracting from a graph patterns with child edges, and to [31,36] which leverage homomorphisms to extract embedded patterns from a tree. We are not aware of any paper on efficiently summarizing embedded tree patterns from a single large data tree.

Conclusion
Data from many modern applications are represented, exchanged and exported in tree-structured form. Large tree datasets are continuously produced by those applications. To produce knowledge from this type of data, we have studied the problem of summarizing frequent embedded tree patterns from large tree datasets. To the best of our knowledge, this problem has not been investigated by existing studies.
We have introduced the concepts of closed and maximal embedded unordered tree patterns and studied their properties in the setting of a single large data tree. We have designed a local closedness checking technique to eagerly eliminate nonclosed patterns. We have further designed pattern search space pruning rules to proactively detect and prune patterns that do not correspond to closed ones. These techniques have been integrated into embedded frequent pattern mining algorithms in order to mine all the maximal and closed embedded frequent patterns from large tree data. The experimental results on synthetic and real datasets demonstrate that, on dense datasets, our approach generates a complete closed and maximal pattern set which is substantially smaller than that generated by the embedded pattern miner, but also runs much faster with negligible overhead on pattern pruning.
Our future work focuses on incorporating user-specified constraints to the proposed approach in order to further reduce the size of the result set and to enable constraint-based mining of compact sets of frequent embedded tree patterns. expansion of P j y by P k z can be shown to be non-closed by an argument similar to the one presented in the proof of Proposition 5.1.
The second case assumes that P i x is a child surrogate of P j y (which means that i = j). By condition (a) of Definition 5.2 for every embedding e of P j y to a data tree T , there is also an embedding of P i x ⊗ s P j y to T which is an extension of e such that the parent of the image of node y is a descendant of the image of node x in T . Every embedding e ′ of P j y ⊗ c P k z to T (remember that we consider a child expansion of P j y by P k z ) maps node z to a descendant of the image of node y under e ′ in T . But then, there is an extension e ′′ of e ′ which maps node x to an ancestor of node y in T . Extension e ′′ is an embedding of (P i x ⊗ c P j y ) ⊗ c (P i x ⊗ c P k z ), i.e., P j y ⊗ c P k z ≡ (P i x ⊗ c P j y ) ⊗ c (P i x ⊗ c P k z ). This implies that P j y ⊗ c P k z is non-closed. Therefore, all the possible expansions on P j y by P k z are not closed also for any P k z ∈ [P ] such that P j y > P k z . Proposition 4 If a pattern has a child or a cousin surrogate, then neither itself nor anyone of its descendants in the pattern search tree can be closed (or maximal).
Proof. Let P i x be a (child or cousin) surrogate of P j y . In order to prove Proposition 4, it suffices to prove that any descendant pattern Q of P j y in the pattern search tree has a superpattern Q ′ , obtained by augmenting Q with a node x, such that Q ≡ Q ′ . If P i x is a child surrogate of P j y , node x is added in Q as the parent of node y. If P i x is a cousin surrogate of P j y , node x is added in Q as the direct left sibling of node y (when i = j), or as the leaf node on the path from the left sibling of node y (when i > j). We will prove this claim by induction on the number of nodes m added to P j y to construct Q. Base Case: m = 1. The base case corresponds to Lemma 5.1 which has been proven above.
Inductive Case: Assuming that the proposition holds for m ≤ n − 1 (n ≥ 2), we prove next that it also holds for m = n. Let node z be the m-th node added to P j y resulting in pattern Q. Let also S be the pattern before the addition of z.
By the inductive assumption, we know that there is some pattern S ′ , obtained by augmenting S with a node x, such that S ≡ S ′ . We construct a pattern Q ′ by attaching z to S ′ in the same position as z was added in Q. We show below that Q ≡ Q ′ .
Consider an embedding e of Q extended to a mapping e ′ which maps node x to T so that its restriction obtained by removing node z is an embedding for S ′ . This is possible by the induction hypothesis. We show next that e ′ is an embedding also for Q ′ . In order to do so, we need to prove that if nodes x and z are not on the same path in Q ′ , their images under e in T are not on the same path either. If nodes x and z are not on the same path in Q ′ , they can have three relative positions in Q ′ : (1) z is a descendant of the rightmost sibling of x; (2) z is a descendant of an ancestor of the parent of x; and (3) z is the rightmost sibling of x. Clearly, in the first two cases, the images of x and z under e cannot be on the same path. Condition (b) in Definition 5.2 and 5.3 guarantees that they cannot be on the same path in the third