Embodiment
In the following detailed description, a large amount of specific detail are proposed, so that provide thorough understanding of the present invention.But, person of skill in the art will appreciate that, even without these specific detail, also can implement the present invention.In other cases, do not describe well-known method, process, assembly and circuit in detail, in order to avoid affect the understanding of the present invention
Illustrative embodiment for a better understanding of the present invention, is briefly described some terms in illustrative embodiment of the present invention below.
Prime number, claims again prime number, refer in being greater than 1 natural number, except 1 and self, the number that cannot be divided exactly by other natural numbers, prime number only has 1 and self two factor.
The main thought that illustrative embodiment in the present invention is set forth is: determinacy and uniqueness while utilizing the product of prime number to carry out Factorization, the structural relation in storage tree between node.Any two nodes in given tree, can judge between these two nodes, whether have forerunner or follow-up relation, the same relation, brotherhood or other relations at constant in the time.
Illustrative embodiment for a better understanding of the present invention, describes some node relationships in illustrative embodiment of the present invention below.
1) forerunner's relation: the father node of node a is the forerunner of node a; The forerunner's of node a father node is also the forerunner of a.
2) follow-up relation: the child node of node a is the follow-up of node a; The follow-up child node of node a is also the follow-up of node a.
3) same relation: node a and node b are same nodes.
4) brotherhood: the father node of the father node of node a and node b is same node.
5) relation the relation other relations: except above 1), 2), 3), 4) providing.
Referring now to Fig. 2, Fig. 2 has provided according to the process flow diagram of the predicate node relation in some illustrative embodiment.
As shown in Figure 2, in some illustrative embodiment, disclose the method for predicate node relation on a kind of tree type data, having comprised:
S11, create the root node of tree type data, create the root node of data tree, attribute data and the characteristic of root node is set;
S12, according to design rule, add the operations such as node, deletion of node,, comprise attribute data and characteristic that interdependent node is set;
First node and Section Point on S13, specified data tree;
S14, according to the attribute data of two nodes and characteristic, judge the relation between described first node and Section Point.
Wherein, described design rule is: each node on data tree has attribute data and characteristic; Except root node, the corresponding different prime number of the attribute data of each node, characteristic is the product of its all forerunner's nodal community data.
Relation in judgement data tree between two nodes, does not need the node in data tree to travel through, and uses attribute data and the characteristic of node to carry out simple computation.The time complexity of decision process is the constant time, does not rely on the degree of depth of node in data tree, more succinct, quick, efficient than existing method.
In some illustrative embodiment, the process for the different prime number of each Node configuration, comprising: from prime generation and administration module, obtaining not used prime number, can be the new prime number producing or the prime number reclaiming after deletion of node in data tree.Wherein, prime generation and administration module are for preserving and produce prime number, and the each prime number using of assurance is unique in data tree.
In some illustrative embodiment, while adding node on described data tree,, also comprise:
On described data tree, specify a node as father node; By prime generation and administration module, be that described interpolation node distributes a prime number as its attribute data, its characteristic is set to the product of all forerunner's nodal community data.
In some illustrative embodiment, during non-root node on deleting described data tree, also comprise:
The father node of all child nodes of deletion of node is set to the father node of described deletion of node, upgrades the characteristic of all descendant nodes of described deletion of node according to described design rule; Prime generation and administration module reclaim the attribute data of described deletion of node.
In some illustrative embodiment, first node and Section Point on specified data tree, according to the attribute data of two nodes and characteristic, judge and comprise the process of relation between described first node and Section Point:
Wherein, a is first node, and b is Section Point, M
aand M
bbe respectively the characteristic of a and b, P
aand P
bbe respectively the attribute data of a and b, <
prerepresent that the former is the latter's forerunner ,=representing that both are same nodes, < > represents that both are the brotgher of node ,/represent that both are other relations.
Below the simple declaration to above-mentioned formula:
If 1. the characteristic of a is greater than the characteristic of b, and the characteristic of a is 0 to the attribute data delivery result of b, and a is the follow-up of b, and b is the forerunner of a; ;
If 2. the characteristic of a is less than the characteristic of b, and the characteristic of b is 0 to the attribute data delivery result of a, and a is the forerunner of b, and b is the follow-up of a; ;
If 3. the attribute data of a is identical with the attribute data of b, a and b are same nodes;
If 4. the attribute data of a is different with the attribute data of b, and the characteristic of a is identical with the characteristic of b, and a and b are brotherhoods;
5. in other situations, a and b belong to other relations.
In some illustrative embodiment, the order of decision node relation can judge according to the deterministic process shown in Fig. 3.
Also disclose preferred data tree herein, Fig. 4 for example, comprising:
The attribute data of the root node of data tree is 1, and characteristic is 0;
The characteristic of all the other arbitrary nodes is the product of its all forerunner's nodal community data.
In some illustrative embodiment, the system of a kind of management data tree is disclosed, comprising:
Prime generation and administration module, data tree administration module;
The effect of prime generation and administration module comprises:
1), when the node on data tree need to distribute prime number, adopt Euclid's sieve method or trying division method to produce next prime number;
2) node on data tree deleted after, reclaim the prime number that the attribute data of deletion of node adopts;
3) guarantee that each prime number using is unique: by the prime number of recovery is preferentially provided, when there is no the prime number reclaiming, produce new prime number for data tree administration module.
The effect of data tree administration module comprises:
1) create data tree
Create the root node of data tree, the data that set a property and characteristic, Fig. 5 for example, the attribute data of root node is 1, characteristic is 0;
2) add node
The father node that adds node is set, and from prime generation and administration module, obtain recovery or newly assigned prime number be set to add the attribute data of node; Characteristic is set to the product of all forerunner's nodal community data, as shown in Figure 6;
3) deletion of node
The father node of all child nodes of deletion of node is set to the father node of deletion of node, and characteristic is set to the characteristic of deletion of node; Recursively the characteristic of these child nodes and descendant node thereof is set to the attribute data of father node and the product of characteristic; The attribute data of deletion of node is recovered to prime generation and administration module, for example, in the data tree shown in Fig. 6, deletes by " software ", and the father node of all child nodes of " software " is set to " infotech ", regeneration characteristics data,, obtain data tree example as shown in Figure 7.
Wherein, in the situation that deletion of node does not exist child node, directly delete this node, reclaim its attribute data.
4) movable part limb
Specify a non-root node, by take its subtree that is root, move to the father node of another appointment, if the father node of this appointment is root node, the characteristic of the root node of subtree is for being set to 1; Otherwise, be set to the attribute data of father node and the product of characteristic.The characteristic of all the other nodes of subtree is the attribute data of its father node and the product of characteristic, Fig. 8 for example, and the subtree that is " software " by root node moves under " trade classification " node, and regeneration characteristics data obtain data tree as shown in Figure 9 after mobile.
Illustrative embodiment disclosed herein can be applied to various tree type grouped datas, for example kind judging under the document in DRS, industry subordinate relation, functional management mechanism subordinate relation, etc., below with the affiliated kind judging of the document in DRS, be specifically described:
The tree type data of example document management as shown in figure 10, the root node of this data tree is trade classification, and its attribute data is 1, and characteristic is 0; The child node of root node is respectively literature, attribute data 2, characteristic 1; Science and engineering, attribute data 3, characteristic 1; Scientific research, attribute data 5, characteristic 1; The child node of science and engineering is respectively physics, attribute data 7, characteristic 3; Chemistry, attribute data 11, characteristic is 3; The child node of physics is respectively quantum physics, attribute data 13, characteristic 21; General physics, attribute data 17, characteristic 21.
When if whether the one piece of document that needs judgement to belong to quantum physics belongs to science and engineering, the attribute data 13 of amount to obtain muon physics, characteristic 21; The attribute data 3 of science and engineering, characteristic 1; According to following formula, calculate:
The characteristic 21 of quantum physics is greater than the characteristic 1 of science and engineering, and 21%3=0, meets the condition of formula in 1., so belong to the document of quantum physics, also belongs to this classification of science and engineering.
In like manner, when whether the one piece of document that needs judgement to belong to quantum physics belongs to literature, because the characteristic 21 of quantum physics is greater than the characteristic 1 of literature, and 21%2 ≠ 0, do not meet the condition of formula in 1., do not meet the 2. 3. condition in 4. of formula yet, so belong to the document of quantum physics, do not belong to this classification of literature.
By above-mentioned computation process, can determine the relation between the two, effectively raise the efficiency that between document, relation is judged.
The explanation of above embodiment is just for helping to understand method of the present invention and core concept thereof., for one of ordinary skill in the art, according to thought of the present invention, all will change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention meanwhile.