Embodiment
Describe the embodiments of the present invention in detail below with reference to accompanying drawing.Process flow diagram in accompanying drawing and block diagram, illustrate the system according to the various embodiments of the present invention, architectural framework in the cards, function and the operation of method and computer program product.In this, each square frame in process flow diagram or block diagram can represent the part of module, program segment or a code, and the part of described module, program segment or code comprises one or more for realizing the executable instruction of logic function of regulation.Also it should be noted that some as alternative realization in, what the function marked in square frame also can be marked to be different from accompanying drawing occurs in sequence.For example, in fact the square frame that two adjoining lands mean can be carried out substantially concurrently, and they also can be carried out by contrary order sometimes, and this determines according to related function.Also be noted that, each square frame in block diagram and/or process flow diagram and the combination of the square frame in block diagram and/or process flow diagram, can realize by the hardware based system of the special use of the function put rules into practice or operation, or can realize with the combination of specialized hardware and computer instruction.
Below with reference to some illustrative embodiments, principle of the present invention and spirit are described.Should be appreciated that providing these embodiments is only in order to make those skilled in the art can understand better and then realize the present invention, and not limit the scope of the invention by any way.For convenience of hereinafter describing, the definition of technical term in paper the application.
As used herein term " social networks " or " social network sites " be point to interested in the special object or just together the people of " saunter " the web website of virtual community is provided.The member communicates by technological means such as voice, chat, instant message, video conference and blogs.And social networks provides other members' of contact good friend's method usually to the member.This website can also be as the medium of in person meeting.
Social networks communicates and mutual ability (noting having " member " and " user " of social networks the implication be equal to, so be used interchangeably) for its user or member provide other users with this social networks.In operation, at first the user of social networks can be logined, and then with its good friend or other users, carries out interaction.Term " good friend " refers to that the user is formed with any other user of connection, association or other relations by social networks as used herein.(but not necessarily) that connection in social networks is normally two-way, so term " good friend " may depend on reference system.Note, the connection between the good friend can be direct connection; Yet some embodiment of social networks allows to form good friend's relation via one-level or multistage indirect connection.
In addition, term " good friend " not necessarily requires the user to be actually friend in actual life, and it only means the relation in social networks.Yet it should be noted that in the present invention, when the good friend knows each other each other in real world, these two good friends usually have good friend's relation in social networks.Not intended distinction acquaintance in embodiments of the present invention, there is good friend's relation, incidence relation and there is limit between the node that means the good friend, in addition with the node table friend that expresses friendship, also not intended distinction good friend and node.Hereinafter, by only how the good friend of oneself being divided into groups with the user in social networks, illustrate and how to realize method and apparatus of the present invention.
Fig. 1 has schematically shown the diagram 100 of the incidence relation between each member in the social networks.As shown in Figure 1, member 101 and member 101 ' are the members in social networks, may there are a plurality of incidence relations between the two: for example, the incidence relation meaned by path 101-111-121-...141-101 ', and the incidence relation meaned by path 101-112-123-...152-101 '.Wherein the dotted line between member 121 and member 141 can mean to have direct good friend's relation, also can mean indirectly incidence relation.Owing in social networks, between each member, concerning complexity, the relation path of finding between current member and target member is the work of a complexity.
Fig. 2 has schematically shown the signal Figure 200 for the method that obtains the relation path between the member according to a solution.According to a solution, can adopt from small to large and successively find with current member and there is the good friend's of incidence relation mode, obtain the relation path between current member and target member.For example, in the example of Fig. 2, member 201 is the target member for current member member 201 ', and expectation obtains the relation path between member 201 and 201 '.
Now, from small to large for different levels, judge successively whether member 201 ' is to have the member of corresponding level good friend relation with current member 201.The numerical value of level is less, shows that incidence relation is tightr, and numerical value more means that incidence relation more becomes estranged.
At first find the member who there is direct good friend's relation with current member 201, for example the member 211 ..., 212}, these members have the member of the 1st level good friend relation with member 201.If these members comprise member 201 ', find a relation path between member 201 and member 201 '.Then, successively find the member { 221,222 who there is the 2nd layer of good friend's relation with current member, ..., 223}, with current member have the 3rd layer of good friend's relation the member 231 ..., 232}, and with current member have the 4th layer of good friend's relation the member 241 ..., 242}, ..., and successively judge in these members whether comprise member 201 '.In this way, can find the relation path between member 201 and member 201 '.
It should be noted that when member in social networks only has less good friend, above-mentioned solution can return results in finite time.Suppose that each member all has N good friend, and, when expectation obtains the relation path that the maximum number of plies is M, good friend's quantity of M layer will reach
thereby, when each member has hundreds of thousands of even more good friends, calculated amount increases rapidly.For example, can comparatively fast return results when M quantity less (, being less than or equal to 3); Yet for example, when the quantity of M will cause returning to result of calculation within the limited stand-by period when large (, being greater than 3).The user does not wish waits for too long on the one hand, wishes again on the other hand to obtain the incidence relation that the number of plies is higher (for example, more than 3 layers), and this has just caused above-mentioned solution to get a desired effect.
In an embodiment of the invention, provide a kind of for obtaining the method for the relation path between the member, having comprised: obtained respectively to there is the first set of incidence relation and there is second of incidence relation with the second member with the first member and gather; Judge whether the first set and the second set have common factor; And there is common factor in response to the first set and the second set, and export at least one relation path between the first member and the second member, wherein a relation path at least one relation path is through the middle member in occuring simultaneously.
Fig. 3 schematically shown according to one embodiment of the present invention for obtaining the method schematic diagram 300 of the relation path between the member.An embodiment of the invention adopt respectively from current member and target member two ends, successively calculate and have the set of incidence relation and judge this intersection of sets collection with these two members respectively.Adopt the advantage of being processed from two ends respectively to be, the calculative number of plies can be reduced to half of original number of plies M, thereby can avoid " explosion type " of number of members in set to increase.
At first, in step S302, obtain respectively to there is the first set of incidence relation and there is second of incidence relation with the second member with the first member and gather.In the context of the present invention, the first member and the second member can transpositions, and for example, when the first member means current member, the second member means the target member; And, when the first member means the target member, the second member means current member.In this embodiment, between each set of special requirement and corresponding member, the number of plies of relation is not identical, for example, the first set can be to have the set of the 2nd layer of incidence relation with the first member, the second set can be to have the set of the 2nd layer of incidence relation with the second member, can also be to have the set of the 3rd layer of incidence relation with the second member.
Then, in step S304, judge whether the first set and the second set have common factor.Can comprise one or more member in common factor, in common factor, included member's quantity equates with the quantity of the relation path of output.
In step S306, there is common factor in response to the first set and the second set, export at least one relation path between the first member and the second member, wherein a relation path at least one relation path is through the middle member in occuring simultaneously.While in occuring simultaneously, having a plurality of middle member, the every paths in the mulitpath of output passes through respectively each the middle member in a plurality of middle members.
In an embodiment of the invention, wherein in response to the first set and the second set, there is common factor, at least one relation path of exporting between the first member and the second member comprises: by the relation path between the middle member in the first member and common factor and the relation path between middle member and the second member, as relation path.Because middle member both had incidence relation with the first member, there is incidence relation with the second member again, thereby adopt the relation path of aforesaid way output, be the relation path that connects the first member and the second member.This first member and the second member each member along the line through path, be connected to each other.Can directly be connected between the first member and middle member, also can indirectly connect through one or more other members.
In an embodiment of the invention, obtain respectively with the first member and there is the first set of incidence relation and comprise with the second set that the second member has an incidence relation: from small to large for each level i, calculate layer by layer the first set and gather with second.Hereinafter, will specifically describe how to obtain relation path referring to Fig. 4 A, Fig. 4 B, Fig. 5 A and Fig. 5 B.Fig. 4 A and Fig. 4 B have schematically shown respectively according to one embodiment of the present invention, schematic diagram 400A and 400B that successively obtain the relation path between the member.
As shown in Figure 4 A, when the relation path between the current member 401A of calculating and target member 401A ', can calculate respectively the first set { 411A that there is the 1st layer of incidence relation with member 401A, ..., 412A}, and calculating and member 401A ' have the 1st layer of incidence relation the second set 411A ' ..., 412A '.Although it should be noted that in each set and only schematically shown 2 members, each set can also comprise more members.Then judge whether the first set and the second set have common factor, suppose that member 411A and member 411A ' are same members, now occur simultaneously for 411A, can obtain relation path: 401A-411A-401A '.
In an embodiment of the invention, from small to large for each level i, calculate layer by layer the first set and second the set comprise: based on the first member have i layer incidence relation first the set, obtain with the first member have i+1 layer incidence relation first the set; And gather based on the second member, thering is second of i layer incidence relation, obtain the second set that there is i+1 layer incidence relation with the second member.
Fig. 4 B has schematically shown to obtain respectively with member 401B and 401B ' has the diagram of the set of the 2nd layer of incidence relation.Member 401B, 401B ' in Fig. 4 B, 411B philosophy are corresponding to member 401A, 401A ' in Fig. 4 A, 411A etc.When obtaining while with member 401B, thering is the set of the 2nd layer of incidence relation, gather { 411B based on member 401B, thering is first of the 1st layer of incidence relation, ..., each member in 412B}, will have the member of good friend's relation as the first set for the 2nd layer of incidence relation with this each member.For the sake of simplicity, in Fig. 4 B, only show member 411B and member 421B ..., 422B has the situation of good friend's relation, the first set that there is the 2nd layer of incidence relation with member 401B for 421B ..., 422B}; Similarly, with member 401B ' have the 2nd layer of incidence relation second the set for 421B ' ..., 422B '.Suppose that member 421B and 421B ' are same members, member 422B and 422B ' are same members, now occur simultaneously for 421B, 422B} can obtain:
Relation path 1:401B-411B-421B-411B '-401B ';
Relation path 2:401B-411B-422B-412B '-401B '.
In an embodiment of the invention, can think that so at this moment good friend's relation becomes and quite becomes estranged, thereby can ignore the good friend's relation more than 7 layers if two members have the association that (contains 7 layers) more than 7 layers.Thereby can only calculate 6 layers with interior relation, if now from current member and target member two ends respectively for each level i set of computations successively, at each member's one end, only need be calculated for 3 levels, now level i meets: 1≤i≤3.
It should be noted that when obtaining while with certain member, having the set of layers 1 and 2 good friend relation, in the low set of the number of plies, member's quantity can excessively rapid growth; And, when obtaining while with certain member, thering is the set of the 3rd layer of good friend's relation, suppose that the set for the 2nd layer comprises tens thousand of members, and each member has 100 good friends, now in the set of the 3rd layer, comprising millions of members.Now calculated amount will be huge, and the reduction of need to taking measures has the member's of high-level incidence relation quantity with current member.
In an embodiment of the invention, taked to diminish the mode of searching.Diminish the principle of searching and be that the whole members in the set based on for the i layer do not obtain the good friend, but only select " star member " in the set based on for the i layer to obtain the good friend when the set of calculating for the i+1 layer.This " star member ", can refer to, this member has more good friend (for example, more than 200 or other numerical value) in social networks, or this member is certain class members of special authentication in social networks.For example, for the student, can think that " squad leader " or " student leader " is star member.With respect to the rank and file, star member may be more important or the people of understanding more, thereby start with and more easily find the associated path between current member and target member from star member's good friend.
Although it should be noted that to diminish to search to lose some relation paths, yet search by for example only just adopting to diminish when calculating the set of the 3rd level, even lost some relation path, these paths also mean the incidence relation of comparatively becoming estranged.In the situation that guarantee to return in real time Query Result, thisly diminish that to search be acceptable.
Particularly, in an embodiment of the invention, also comprise: according to thering is the first set of i layer incidence relation and the attribute of the member in the second set with the first member and the second member respectively, the first set and the second set are screened; And the first set based on after screening and the second set, calculate the first set and the second set that there is respectively i+1 layer incidence relation with the first member and the second member.In this embodiment, social networks can be rank and file and star member by member classifying, and the member who is " star " using attribute is as the basis of calculating for the set of i+1 layer.
In an embodiment of the invention, also comprise: according to there is respectively the first set and the member in the second set and the quantity of other members' incidence relation of i layer incidence relation with the first member and the second member, the first set and second is gathered and screened; And the first set based on after screening and the second set, calculate the first set and the second set that there is respectively i+1 layer incidence relation with the first member and the second member.In this embodiment, predetermined threshold (for example, 200) can be set, when the good friend's quantity of the member in the set for the i layer is less than 200, this member is rejected.Then, the set for the i+1 layer is calculated in the set based on after screening.
Embodiments of the present invention provide a kind of from current member and target member two ends, obtain symmetrically the method for good friend's set separately.According to an embodiment of the invention, this " symmetry " can comprise set the judgement common factor that simultaneously obtains next level from two ends; Can also comprise the set that first from an end, at first obtains next level, and judgement then obtains set the judgement common factor of next level again for the common factor between the set of the set of next level of this end and current level for the other end for the other end.It should be noted that " end " here can refer to any one in current member and target member, and " other end " can refer to remaining another.
In other words, in an embodiment of the invention, the first set has i layer incidence relation with the first member, and the second set has i layer incidence relation with the second member; In an embodiment of the invention, the first set has i layer incidence relation with the first member, and the second set has i-1 layer incidence relation with the second member.
Fig. 5 A and Fig. 5 B have schematically shown respectively, schematic diagram that successively obtain relation path member between another embodiment according to the present invention.As shown in Figure 5A, obtain with member 501A have the 1st layer of incidence relation set 511A ..., 512A} and with member 501A ' have the 1st layer of incidence relation set 511A ' ..., 512A ' afterwards, can at first calculate the set { 521A that there is the 2nd layer of incidence relation with the member, ..., 522A}, and calculate: { 521A, ..., 522A} ∩ 511A ' ..., 512A ' }.Suppose that now member 521A is identical member with member 511A ', obtain relation path: 501A-511A-521A-501A '.
Similarly in Fig. 5 B, when keeping member 501B mono-end constant and at first calculate and there is the set of the 2nd layer of incidence relation with member 501B ' and while seeking common ground, can obtain relation path: 501B-511B-511B '-501B ' (supposing that member 511B and 521B ' are identical members).
Fig. 6 schematically shown according to one embodiment of the present invention for obtaining the device schematic diagram 600 of the relation path between the member.In an embodiment of the invention, provide a kind of for obtaining the device of the relation path between the member, comprise: deriving means 610 is configured for to obtain respectively to have the first set of incidence relation and have second of incidence relation with the second member with the first member and gathers; Judgment means 620, be configured for and judge whether the first set and the second set have common factor; And output unit 630, be configured in response to the first set and the second set and there is common factor, export at least one relation path between the first member and the second member, wherein a relation path at least one relation path is through the middle member in occuring simultaneously.
In an embodiment of the invention, output unit 630 comprises: by the relation path between the middle member in the first member and common factor and the relation path between middle member and the second member, as relation path.
In an embodiment of the invention, deriving means 610 comprises: calculation element, be configured for from small to large for each level i, and calculate layer by layer the first set and the second set.
In an embodiment of the invention, calculation element comprises: the first deriving means, and be configured for based on the first member, thering is first of i layer incidence relation and gather, obtain the first set that there is i+1 layer incidence relation with the first member; And second deriving means, be configured for based on the second member, thering is the second set of i layer incidence relation, obtain the second set that there is i+1 layer incidence relation with the second member.
In an embodiment of the invention, also comprise: the first screening plant, be configured for according to thering is the first set of i layer incidence relation and the attribute of the member in the second set with the first member and the second member respectively, the first set and the second set are screened; And first calculation element, be configured for the first set and the second set based on after screening, calculate respectively the first set and second that there is i+1 layer incidence relation with the first member and the second member and gather.
In an embodiment of the invention, also comprise: the second screening plant, be configured for according to there is respectively the first set and the member in the second set and the quantity of other members' incidence relation of i layer incidence relation with the first member and the second member, the first set and second is gathered and screened; And second calculation element, be configured for the first set and the second set based on after screening, calculate respectively the first set and second that there is i+1 layer incidence relation with the first member and the second member and gather.
In an embodiment of the invention, the first set has i layer incidence relation with the first member, and the second set has i layer incidence relation with the second member.
In an embodiment of the invention, the first set has i layer incidence relation with the first member, and the second set has i-1 layer incidence relation with the second member.
In an embodiment of the invention, level i meets: 1≤i≤3.
Fig. 7 shows the schematic block diagram that is suitable for the computer system for putting into practice embodiment of the present invention.As shown in Figure 7, computer system can comprise: CPU (CPU (central processing unit)) 701, RAM (random access memory) 702, ROM (ROM (read-only memory)) 703, system bus 704, hard disk controller 705, keyboard controller 706, serial interface controller 707, parallel interface controller 708, display controller 709, hard disk 710, keyboard 711, serial external unit 712, parallel external unit 713 and display 714.In these equipment, with system bus 704 coupling CPU 701, RAM 702, ROM 703, hard disk controller 705, keyboard controller 706, serialization controller 707, parallel controller 708 and display controller 709 arranged.Hard disk 710 and hard disk controller 705 couplings, keyboard 711 and keyboard controller 706 couplings, serial external unit 712 and serial interface controller 707 couplings, parallel external unit 713 and parallel interface controller 708 couplings, and display 714 and display controller 709 couplings.Should be appreciated that the structured flowchart shown in Fig. 7 illustrates just to the purpose of example, rather than limitation of the scope of the invention.In some cases, can increase or reduce as the case may be some equipment.
Should be appreciated that the structured flowchart shown in Fig. 7 illustrates just to the purpose of example, rather than limitation of the scope of the invention.In some cases, can increase or reduce as the case may be some equipment.
It should be noted that embodiments of the present invention can realize by the combination of hardware, software or software and hardware.Hardware components can utilize special logic to realize; Software section can be stored in storer, and by suitable instruction execution system, for example microprocessor or special designs hardware are carried out.Those having ordinary skill in the art will appreciate that above-mentioned equipment and method can and/or be included in the processor control routine with computer executable instructions realizes, for example, at the mounting medium such as disk, CD or DVD-ROM, provide such code on such as the programmable memory of ROM (read-only memory) (firmware) or the data carrier such as optics or electronic signal carrier.Equipment of the present invention and module thereof can be by such as VLSI (very large scale integrated circuit) or gate array, realize such as the semiconductor of logic chip, transistor etc. or such as the hardware circuit of the programmable hardware device of field programmable gate array, programmable logic device etc., also can use the software of being carried out by various types of processors to realize, also can realizing in conjunction with for example firmware by above-mentioned hardware circuit and software.
The communication network of mentioning in instructions can comprise disparate networks, include but not limited to LAN (Local Area Network) (" LAN "), wide area network (" WAN "), according to the network of IP agreement (for example, the Internet) and ad-hoc network (for example, ad hoc peer-to-peer network).
Although it should be noted that some devices or the sub-device of having mentioned equipment in above-detailed, this division is only not enforceable.In fact, according to the embodiment of the present invention, the feature of above-described two or more devices and function can be specialized in a device.Otherwise, the feature of an above-described device and function can Further Division for to be specialized by a plurality of devices.
In addition, although described in the accompanying drawings the operation of the inventive method with particular order,, this not requires or hint must be carried out these operations according to this particular order, or the operation shown in must carrying out all could realize the result of expectation.On the contrary, the step of describing in process flow diagram can change execution sequence.Additionally or alternatively, can omit some step, a plurality of steps be merged into to a step and carry out, and/or a step is decomposed into to a plurality of steps carries out.
Although with reference to some embodiments, described the present invention, should be appreciated that, the present invention is not limited to disclosed embodiment.The present invention is intended to contain interior included various modifications and the equivalent arrangements of spirit and scope of claims.The scope of claims meets the most wide in range explanation, thereby comprises all such modifications and equivalent structure and function.