Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, the present invention is described in further detail below in conjunction with the accompanying drawings and the specific embodiments.Need to prove, in the situation that do not conflict, the embodiment in the application and the feature in embodiment be combination in any mutually.
Fig. 1 is the schematic flow sheet of the output intent embodiment of resource information provided by the invention.Embodiment of the method shown in Figure 1 comprises:
Step 101, obtain the dependence of other resource nodes on resource in each resource node and system;
Wherein this dependence can be obtained by user's input mode.
Step 102, for described each resource node is distributed in the position of resource hierarchy, it is the resource that is less than or equal to the individual resource node of i that the Resource Dependence that wherein is positioned at the resource node of i+1 level is positioned at level, wherein, i=1,2...... N, N are positive integer;
Specifically, if the resource of the Resource Dependence resource node 2 of resource node 1, can claim resource node 1 for relying on resource node, resource node 2 is relied on resource node, the principle of above-mentioned generation resource hierarchy be exactly rely on the level of resource node will be lower than the level of the resource node that is relied on.Certainly, quilt dependence resource node in some dependences might be also the dependence resource node in another dependence, in like manner, dependence resource node in some dependences might be also that the quilt in another dependence relies on resource node, but, complementary situation can not appear.
For instance, the relation of resource node and other resource nodes determines the hierarchical position of this resource node in figure, and the principle of following is, resource node place layer is at least lower one deck of all resources that depend on it.
Step 103, to obtain gap between two residing levels of resource node of Existence dependency relationship be one group of resource node of 1;
If the gap between the two residing levels of resource node of Existence dependency relationship is not 1, all increase by a dummy node on each layer between two resource place layers, two resource nodes are connected by this dummy node.
For instance, if resource node A and B Existence dependency relationship, if resource node A is at the 1st layer, resource node B is at the 4th layer, the level between two resource node place layers is layers 2 and 3, can all increase by a dummy node in layers 2 and 3, be connected by the dummy node that increases between resource node A and resource node B, thereby under the prerequisite that has embodied the dependence between resource node A and B, guaranteed that again the gap between two residing levels of resource node of Existence dependency relationship is 1.
In fact, dummy node is divided into two sections with a relation, and it will play the effect of forming a connecting link in the intermediate level of cross-layer relation.Dummy node can be thought a virtual resource node, and it connects as the part of figure the resource node that has the cross-layer relation.Certainly, if exist two to concern that the level between resource is poor greater than 2, can recurrence insert dummy node, until there is not the cross-layer relation.This process is called the stratification process of figure, through this step, can obtain the directed graph of a stratification.
Step 104, take the middle-level gap of same dependence as 1 as benchmark, two resource nodes in the join dependency relation obtain the directed graph of dependence;
The directed graph of step 105, the described dependence of output.
Still above example describes, the resource node A of level 1 connects the dummy node that be positioned at level 2 corresponding with this dependence, and this dummy node that is positioned at level 2 connects the dummy node that be positioned at level 3 corresponding with this dependence, and this dummy node that is positioned at level 3 is connected with the resource node B of level 4 again simultaneously.
Need to prove, in the present embodiment, with icon representation resource node and dummy node, straight line represents relation.Through the stratification process of figure, can determine no longer to exist in figure the straight line of cross-layer, so, next problem is exactly how to reduce the number in the straight line crosspoint of causing due to rectilinear direction difference between level in figure.Because internodal relation is fixed, thus in every layer the determining positions of node the number in crosspoint in figure during visable representation, to reduce the crosspoint number as target, the node location in level is sorted.The present embodiment adopts the placement algorithm based on the center of gravity sequence, guarantees that final figure crosspoint number of showing is minimum.
At first it should be explicitly made clear at this point, in figure, vertical index of resource node and dummy node is its residing level, is topmost ground floor.And laterally index is its residing horizontal position in level, is set to 1 from leftmost bit, and turning right increases progressively.Node is defined as in adjacent bed all and the horizontal index sum of the related node of this node and the business of adjacent bed node number with respect to the center of gravity of adjacent bed.
The flow process of resetting is described:
Steps A, calculate the i node layer with respect to the first center of gravity of node on the i-1 layer with respect to the second center of gravity of node on the i+1 layer, set maximum sequence number of times, wherein:
The first center of gravity of i layer single node is that the business of total number of the node of dependence is arranged with this node on the horizontal index sum of the node that is connected with this node of i-1 layer and i-1 layer;
The second center of gravity of i layer single node is that the business of total number of the node of dependence is arranged with this node on the horizontal index sum of the node that on the i+1 layer, node is connected with this node and i+1 layer;
Preferably, maximum sequence number of times is traditionally arranged to be total number of plies of resource;
Step B, the order according to level i from 2 to N are fixed the node of i-1 layer, sort from small to large according to the first center of gravity on the i layer, and the intersection of calculating after sequence is counted;
Step C, the order according to level i from 2 to N are directed to the position of the identical node of the first center-of-gravity value on the i-1 layer on transposing i layer, the intersection of calculating after sequence is counted;
Step D, according to the order of level from N-1 to 1, fix the node of i+1 layer, sort from small to large according to the second center of gravity on the i layer, the intersection of calculating after sequence is counted;
If it is 0 that the intersection that calculates in step e B, C, D is counted, preserve ranking results, reset flow process and finish.
If step F B, C, D cycle-index reach the maximum sequence number of times of setting, preserve intersection that step B, C and D the calculate minimum result of counting, reset flow process and finish.
In embodiments of the present invention, it is lower, relative that the resource node that is relied on is in level, and the level that the resource node of dependence is in is higher.According to the resource distribution principle, on number, on lower level, the node of each level lacks than the node of higher level, therefore, when execution in step B, by the order from 2 to N according to level, the position on every node layer is reset, obtain intersecting and count, on this basis, whether execution in step C can make crossing number reduce with the position of attempting the identical node of replacing center-of-gravity value, whether execution in step E, have the minimum arrangement mode of crossing number by changing the further trial of rearrangement order again.
Wherein the order of above-mentioned steps B and D can be changed, and carries out B if first carry out D again, need add after D or B so a step equidirectional on to the operation of identical focus point switch.B and D adjust relation on the directed graph level from both direction, the order adjustment that this two step only need have the back in a step to increase the identical node of center of gravity gets final product, this is to adjust the situation that can obtain more excellent result after identical center of gravity node in order to guarantee not ignore, and avoids again all will adjusting center of gravity same node point order after each adjustment order.
In simple terms, above-mentioned said sequence flow process can also be replaced by following steps, is specially:
Step 1, according to the order of level i from N-1 to 1, fix the node of i+1 layer, according on the i layer with respect to the center of gravity of lower level node namely the second center of gravity sort from small to large, the intersection of calculating after sequence is counted;
Step 2, according to the order of level i from N-1 to 1, be directed to the position of the identical node of lower level node center-of-gravity value on transposing i layer, the position of the node that namely the second center-of-gravity value is identical, the intersection of calculating after sequence is counted;
Step 3, the order according to level i from 2 to N are fixed the node of i-1 layer, sort from small to large according to the first center of gravity on the i layer, and the intersection of calculating after sequence is counted.
The below describes with an application example:
The schematic diagram of the directed graph of the dependence that Fig. 2 provides for the embodiment of the present invention.In figure shown in Figure 1, a two-layer directed graph is arranged, node A depends on node C and node D, and Node B depends on node C, like this, a crosspoint is just arranged in figure.The center of gravity of node is relative.A node is defined as the average index value of all nodes related with it in all adjacent beds with respect to the center of gravity of adjacent bed.Wherein, node A depends on node C and node D, and the horizontal index of these two nodes is respectively 1 and 2, so node A is with respect to the center-of-gravity value (1+2) of lower floor/2=1.5.In like manner, Node B is C with respect to the node of lower floor, and namely with B, the number of the node of dependence being arranged is 2, and the horizontal index value of C is 1, B is 1 with respect to the center-of-gravity value of lower level node, and node C is 1.5 with respect to the center of gravity of upper layer node, and node D is 1 with respect to the center of gravity of upper layer node.
And refer to fix a node layer based on the sequence of center of gravity, the node of its adjacent level is carried out the center of gravity sequence.In Fig. 2, fixedly ground floor, sort to second layer node, because the center of gravity of D is 1 center of gravity 1.5 less than C, so with C and D switch, obtain new directed graph, be Fig. 3, namely Fig. 3 is the schematic diagram of the directed graph that directed graph shown in Figure 2 carried out obtain after center of gravity is reset.
Can be seen by Fig. 3, the crosspoint number in Fig. 3 becomes 0.Same, also fixing second layer node, sort to the ground floor node, and the center of gravity 1.5 of A is greater than the center of gravity 1 of B, and A and B to change place, also can be obtained the crosspoint and be 0 node.
Certainly, for multi-layer graphical, according to from the top down or order from bottom to top sort successively.It needs to be noted, for calculating the identical node of center-of-gravity value, their relative order may affect final result, so after completing a sequence of taking turns from the top down, will be according to the equidirectional node reversing of position identical to center-of-gravity value, to determine the impact minimum on the crosspoint.
After completing based on the layout of center of gravity sequence, obtain the horizontal and vertical index of the final node of determining, according to the size of the painting canvas that will show, with its drafting and display.Icon and corresponding relation that node is corresponding are carried out visual presentation, in the painting canvas of fixing and variable-size, depict resource node and inter-resource relation, if need the showing resource monitoring, describe resource status.
Certainly, in actual applications, if the dependence of adding resource is arranged, according to the dependence that newly adds, if the hierarchical position of new resources and related resource thereof more is during the dependence of deletion resource, according to the dependence of deletion, the more hierarchical position of new resources and related resource thereof.
This shows, the present invention has represented the relation between resource intuitively by the directed graph of the dependence between the output resource information.
Fig. 4 is the structural representation of the output system embodiment of resource information provided by the invention.In conjunction with embodiment of the method shown in Figure 1, system shown in Figure 4 embodiment comprises:
Deriving means 401 is used for obtaining each resource node and the dependence of other resource nodes of system on resource;
The first distributor 402, be connected with described deriving means 401, be used to described each resource node to be distributed in the position of resource hierarchy, it is the resource that is less than or equal to the resource node of i that the Resource Dependence that wherein is positioned at the resource node of i+1 level is positioned at level, i=1 wherein, 2...... N, N are positive integer;
Jockey 403 is connected with described the first distributor 402, and the gap that is used between the two residing levels of resource node of Existence dependency relationship is at 1 o'clock, connects two resource nodes in each dependence, obtains the directed graph of dependence;
Output device 404 is connected with described jockey 403, is used for the flow process of the directed graph of the described dependence of initiation output.
Optionally, described system also comprises:
The second distributor, be connected with jockey 403 with described the first distributor 402, be used for gap between the two residing levels of resource node of Existence dependency relationship greater than 1 o'clock, distribute one to one a dummy node between two resource node place levels in described dependence, then trigger dependence directed graph obtain flow process.
Specifically, described output device comprises:
The first computing module, be used for to calculate the i node layer with respect to the first center of gravity of node on the i-1 layer with respect to the second center of gravity of node on the i+1 layer, set maximum sequence number of times, wherein: the first center of gravity of each node of i layer is with this node, the business of total number that the node of dependence is arranged with this node to be arranged on the index sum of all nodes of dependence and i-1 layer on the i-1 layer; The second center of gravity of each node of i layer is that the business of total number of the node of dependence is arranged with this node on the horizontal index sum of all nodes that on the i+1 layer, node and this node have dependence and i+1 layer;
The first order module is used for carrying out the sequence flow process, and described sequence flow process comprises:
Step 1, the order according to level i from 2 to N are fixed the node of i-1 layer, sort from small to large according to the first center of gravity on the i layer, and the intersection of calculating after sequence is counted;
Step 2, the order according to level i from 2 to N are directed to the position of the node that on the i-1 layer, the first center-of-gravity value is identical on transposing i layer, the intersection of calculating after sequence is counted;
Step 3, according to the order of level i from N-1 to 1, fix the node of i+1 layer, sort from small to large according to the second center of gravity on the i layer, the intersection of calculating after sequence is counted;
The first output module, being used for counting in the intersection that step 1,2,3 calculates is 0 o'clock, preserves ranking results and output, perhaps, when step 1,2,3 cycle-indexes reach the maximum sequence number of times of setting, preserve the intersection of calculating in step 1,2,3 count minimum result and output.
Specifically, described output device comprises:
The second computing module, be used for to calculate the i node layer with respect to the first center of gravity of node on the i-1 layer with respect to the second center of gravity of node on the i+1 layer, set maximum sequence number of times, wherein: the first center of gravity of each node of i layer is with this node, the business of total number that the node of dependence is arranged with this node to be arranged on the horizontal index sum of all nodes of dependence and i-1 layer on the i-1 layer; The second center of gravity of each node of i layer is that the business of total number of the node of dependence is arranged with this node on the horizontal index sum of all nodes that on the i+1 layer, node and this node have dependence and i+1 layer;
The second order module is used for carrying out the sequence flow process, and described sequence flow process comprises:
Step 1, according to the order of level from N-1 to 1, fix the node of i+1 layer, sort from small to large according to the second center of gravity on the i layer, the intersection of calculating after sequence is counted;
Step 2, the order according to level i from 2 to N are directed to the position of the node that on the i-1 layer, the second center-of-gravity value is identical on transposing i layer, the intersection of calculating after sequence is counted;
Step 3, the order according to level i from 2 to N are fixed the node of i-1 layer, sort from small to large according to the first center of gravity on the i layer, and the intersection of calculating after sequence is counted;
The second output module, being used for counting in the intersection that step 1,2,3 calculates is 0 o'clock, preserves ranking results and output, perhaps, when step 1,2,3 cycle-indexes reach the maximum sequence number of times of setting, preserve the intersection of calculating in step 1,2,3 count minimum result and output.
Compared with prior art, by the Resource Dependence relation between the directed graph output node, simple and directly perceived.
The all or part of step that one of ordinary skill in the art will appreciate that above-described embodiment can realize with the computer program flow process, described computer program can be stored in a computer-readable recording medium, described computer program (as system, unit, device etc.) on corresponding hardware platform is carried out, when carrying out, comprise step of embodiment of the method one or a combination set of.
Alternatively, all or part of step of above-described embodiment also can realize with integrated circuit, and these steps can be made into respectively integrated circuit modules one by one, perhaps a plurality of modules in them or step is made into the single integrated circuit module and realizes.Like this, the present invention is not restricted to any specific hardware and software combination.
Each device/functional module/functional unit in above-described embodiment can adopt general calculation element to realize, they can concentrate on single calculation element, also can be distributed on the network that a plurality of calculation elements form.
Each device/functional module/functional unit in above-described embodiment is realized with the form of software function module and during as independently production marketing or use, can be stored in a computer read/write memory medium.The above-mentioned computer read/write memory medium of mentioning can be read-only memory, disk or CD etc.
The above; be only the specific embodiment of the present invention, but protection scope of the present invention is not limited to this, anyly is familiar with those skilled in the art in the technical scope that the present invention discloses; can expect easily changing or replacing, within all should being encompassed in protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the described protection range of claim.