A method for finding a target subgraph in a bipartite graph and related devices
By finding the maximum (a,b)-biplex graph in a bipartite graph, and utilizing the Branch-and-Bound method and asymptotic boundary framework to update the lower bound and delete vertices, the problem of insufficient correlation extraction in many-to-many data is solved, achieving efficient extraction of user and content data and product recommendation.
Patent Information
- Application Number
- CN202211441505.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-17
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2042-11-17
AI Technical Summary
Existing technologies lack efficient methods for extracting more relevant user and content data from large amounts of many-to-many data, and there is a lack of extraction methods based on the number of missing data in the correspondence.
By finding the maximum (a,b)-biplex graph in the bipartite graph, using the Branch-and-Bound method and asymptotic boundary framework, updating the first and second lower bounds, deleting some vertices, a reduced bipartite graph is obtained. The target optimal solution is then updated through local optima, and finally the target subgraph that satisfies the degree difference is found.
It enables efficient extraction of more relevant user and content data from many-to-many datasets, supporting more accurate product recommendations on the platform.
Smart Images

Figure CN115795104B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data analysis, in particular to a method for searching a target subgraph in a bipartite graph and related equipment. BACKGROUND
[0002] In practical applications, many data are not simply one-to-one, but many-to-many, such as the correspondence between users and content of a platform. In order to realize product recommendation functions, it is necessary to extract as much data as possible of the correspondence between users and content with high relevance from a large amount of many-to-many data for analysis. However, efficient methods for extracting data of the correspondence between users and products with higher relevance from a large amount of many-to-many data are rare in the prior art, and there is no extraction method based on the number of missing data in the correspondence.
[0003] Therefore, the prior art still needs to be improved and enhanced. SUMMARY
[0004] In view of the above defects of the prior art, the present application provides a method for searching a target subgraph in a bipartite graph, aiming to solve the problem of the lack of efficient methods for extracting data of the correspondence between users and products with higher relevance from a large amount of many-to-many data in the prior art.
[0005] To solve the above technical problems, the technical solution adopted by the present application is as follows:
[0006] In a first aspect of the present application, a method for searching a target subgraph in a bipartite graph is provided, the method comprising:
[0007] obtaining an original bipartite graph, the original bipartite graph comprising a plurality of first vertices and a plurality of second vertices, wherein any two of the first vertices are not connected to each other, and any two of the second vertices are not connected to each other, and obtaining the degrees of the first vertices and the second vertices;
[0008] updating a first lower bound value, updating a second lower bound value according to a current target optimal solution, and deleting part of the vertices in the original bipartite graph according to the degrees of the first vertices and the second vertices and the first lower bound value and the second lower bound value to obtain a reduced bipartite graph;
[0009] obtaining a local optimal solution according to the degrees of the first vertices and the second vertices in the reduced bipartite graph, and updating the target optimal solution according to the local optimal solution;
[0010] re-performing the steps of updating the first lower bound value and updating the second lower bound value according to the current target optimal solution until the first lower bound value is not greater than a minimum preset lower bound, wherein an initial value of the first lower bound value is a sum of a maximum degree of the first vertex and the first preset threshold value, and an initial value of the local optimal solution is an empty graph;
[0011] taking the latest target optimal solution as the target subgraph, the target subgraph being a subgraph in the original bipartite graph that contains the largest number of vertices and satisfies a target condition, the target condition being that a degree of each first vertex in the subgraph is not less than a difference between a number of second vertices in the subgraph and the first preset threshold value and a degree of each second vertex is not less than a difference between a number of first vertices in the subgraph and the second preset threshold value.
[0012] In a second aspect, the present application provides a device for searching a target subgraph in a bipartite graph, comprising:
[0013] an initial solution generation module configured to obtain an original bipartite graph, the original bipartite graph comprising a plurality of first vertices and a plurality of second vertices, wherein any two first vertices are not connected to each other, any two second vertices are not connected to each other, and degrees of the first vertices and the second vertices are obtained;
[0014] a bipartite graph reduction module configured to update a first lower bound value, update a second lower bound value according to a current target optimal solution, and delete part of vertices in the original bipartite graph according to degrees of the first vertices and the second vertices and the first lower bound value and the second lower bound value to obtain a reduced bipartite graph;
[0015] a local optimal solution obtaining module configured to obtain a local optimal solution according to degrees of the first vertices and the second vertices in the reduced bipartite graph, and update the target optimal solution according to the local optimal solution;
[0016] an iteration module configured to re-perform the steps of updating the first lower bound value and updating the second lower bound value according to the current target optimal solution until the first lower bound value is not greater than a minimum preset lower bound, wherein an initial value of the first lower bound value is a sum of a maximum degree of the first vertex and the first preset threshold value, an initial value of the second lower bound value is a difference between an initial value of the local optimal solution and the initial value of the first lower bound value, and an initial value of the local optimal solution is an empty graph;
[0017] A subgraph obtaining module is configured to take the latest target optimal solution as the target subgraph, the target subgraph being a subgraph with the largest number of vertices in the original bipartite graph and meeting a target condition, the target condition being that the degree of each first vertex in the subgraph is not less than the difference between the number of second vertices in the subgraph and a first preset threshold, and the degree of each second vertex in the subgraph is not less than the difference between the number of first vertices in the subgraph and a second preset threshold.
[0018] In a third aspect, the present application provides a terminal, comprising a processor, a computer readable storage medium connected with the processor, the computer readable storage medium is adapted to store a plurality of instructions, the processor is adapted to call the instructions in the computer readable storage medium, to perform the steps of the bipartite graph target subgraph finding method.
[0019] In a fourth aspect, the present application provides a computer readable storage medium, the computer readable storage medium stores one or more programs, the one or more programs can be executed by one or more processors to implement the steps of the bipartite graph target subgraph finding method.
[0020] Compared with the prior art, the present application provides a bipartite graph target subgraph finding method and related equipment, the bipartite graph target subgraph finding method provided by the present application converts the problem of extracting as much as possible the more relevant part of data of users and content from a large number of many-to-many data into the problem of finding the subgraph with the largest number of vertices from the subgraph meeting the condition that the degree of each first vertex is not less than the difference between the number of second vertices in the subgraph and a first preset threshold, and the degree of each second vertex is not less than the difference between the number of first vertices in the subgraph and a second preset threshold, thereby achieving the effect of efficiently extracting as much as possible the more relevant part of data of users and content from a large number of many-to-many data. BRIEF DESCRIPTION OF DRAWINGS
[0021] Figure 1 The flowchart of the embodiment of the bipartite graph target subgraph finding method provided by the present application;
[0022] Fig. 2(a) is a schematic diagram of a bipartite graph and a bipartite graph subgraph Figure 1 ;
[0023] Fig. 2(b) is a schematic diagram of a bipartite graph and a bipartite graph subgraph
[0024] Fig. 2(c) is a schematic diagram of a bipartite graph and a bipartite graph subgraph Figure 3 ;
[0025] Figure 3The embodiment of the method for searching a target subgraph in a bipartite graph provided by the application is shown in the overall algorithm pseudocode diagram;
[0026] Figure 4 The embodiment of the method for searching a target subgraph in a bipartite graph provided by the application is shown in the overall algorithm pseudocode diagram;
[0027] Figure 5 The embodiment of the method for searching a target subgraph in a bipartite graph provided by the application is shown in the overall algorithm pseudocode diagram;
[0028] Figure 6 The embodiment of the method for searching a target subgraph in a bipartite graph provided by the application is shown in the overall algorithm pseudocode diagram;
[0029] Figure 7 The embodiment of the method for searching a target subgraph in a bipartite graph provided by the application is shown in the overall algorithm pseudocode diagram; DETAILED DESCRIPTION
[0030] To make the objectives, technical solutions and effects of the application clearer and more explicit, the application is further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the application and do not limit the application.
[0031] The method for searching a target subgraph in a bipartite graph provided by the application can be applied to a terminal with computing capability, which can execute the method for searching a target subgraph in a bipartite graph provided by the application to obtain a target subgraph. The terminal can be, but is not limited to, various computers, mobile terminals, smart home appliances, wearable devices, etc.
[0032] Embodiment one
[0033] The structure of a graph is widely used in social sciences and social networks. An important direction in graph theory is the discovery of dense subgraphs. The exploration and discovery of maximum cliques have attracted the research of many scholars over the years. The goal of maximum clique is to maximize the total number of vertices contained in a subgraph. Because the structure of a cluster requires too much tightness of a graph, some other dense subgraphs based on different conditions are extended, such as k-core, k-plex, etc. Thus, the maximum subgraph search problem for different models is extended.
[0034] This embodiment proposes a new dense subgraph model of a bipartite graph: (a, b)-biplex. The (a, b)-biplex model is extended from k-plex in a simple graph. This model allows the vertices of two parts in a dense subgraph of a bipartite graph to be missing a certain degree, i.e., in a bipartite graph G = (L, R, E), a dense subgraph is a biplex (L', R', E') such that |L'| = |L| - a, |R'| = |R| - b, and |L'| |R'| = |L| |R| - a * b. L | and R = |n RIn the (a,b)-biplex graph, the degree of the midpoint of L is at least |n. R |-a, the degree of the midpoint of R is at least |n L |-b. An algorithm for finding the maximum (a,b)-biplex in a bipartite graph is used, integrating the model's properties into the Branch-and-Bound method and employing an asymptotic boundary framework to improve search efficiency. This addresses the problem of finding the correspondence between users and content on a platform, enabling content recommendations to be tailored to the target audience and maximizing benefits. The (a,b)-biplex graph is defined as the target word graph to be searched from the bipartite graph in this embodiment. The specific steps are as follows.
[0035] like Figure 1 As shown, one embodiment of the target subgraph search method in the bipartite graph includes the following steps:
[0036] S100. Obtain the original bipartite graph, which includes multiple first vertices and multiple second vertices, wherein any two first vertices are not connected to each other, and any two second vertices are not connected to each other. Obtain the degree of the first vertices and the degree of the second vertices.
[0037] The original bipartite graph is obtained based on the correspondence data between users and content on one or more platforms. Content can include products, videos, articles, etc., depending on the nature of the platform. For example, on a shopping platform, the content can be products; on a social platform, the content can be blog posts, created videos, etc. Each first vertex in the original bipartite graph corresponds to a user on the platform, and each second vertex corresponds to a piece of content on the platform. The edges in the original bipartite graph are obtained based on the association between users and content on the platform. For example, when a user buys, favorites, views, or likes a piece of content, there is a connecting edge between the first vertex corresponding to that user and the second vertex corresponding to that content. The number of edges connecting each vertex to other vertices is called the degree of that vertex.
[0038] In order to facilitate users in a platform to quickly access to the content they need or are interested in, many platforms will adopt the recommendation mode, that is, according to the historical associated content of the user or the personal information of the user to determine the content that the user may need or be interested in and display on the page of the user. In the embodiment, the recommendation is realized by finding a target subgraph in the original bipartite graph, the target subgraph is the largest (a, b)-biplex graph, so that the largest connection relationship between a specific group of people and a specific content can be found under the given a and b, to realize the product recommendation function, a and b can be set according to the actual recommendation needs of the platform, if a smaller range of recommendation is needed, a and b can be set smaller, if a larger range of recommendation is needed, a and b can be set larger, specifically, the association between all first vertices and all second vertices in the target subgraph is strong, the users corresponding to all first vertices in the target subgraph can be considered to have similar selection orientation, the content corresponding to the second vertices in the target subgraph is recommended to the users corresponding to the first vertices in the target subgraph, to realize more accurate content recommendation.
[0039] Fig. 2(a), Fig. 2(b), Fig. 2(c) is an example in the embodiment, assuming that Fig. 2(a) is a given original bipartite graph, Fig. 2(b) is the largest (1, 1)-biplex in Fig. 2(a), and Fig. 2(c) is a (1, 1)-biplex in Fig. 2(a). Such a problem is simply written as MBIP (Maximum Biplex Problem) in the embodiment.
[0040] When the original bipartite graph is obtained according to the users in the platform and the corresponding content, the following steps are performed:
[0041] S200, updating the first lower bound value, updating the second lower bound value according to the current target optimal solution, deleting part of the vertices in the original bipartite graph according to the degree of the first vertex and the degree of the second vertex and the first lower bound value and the second lower bound value, and obtaining a reduced bipartite graph.
[0042] Among them, the first lower bound value is updated to a first value, wherein the first value is less than the current first lower bound value;
[0043] The second lower bound value is updated according to the current target optimal solution, including:
[0044] The second lower bound value is updated to the difference between the number of vertices in the current target optimal solution and the current first lower bound value.
[0045] For a bipartite graph, the size of the optimal solution depends on the number of first vertices and second vertices. In the embodiment, two integer values lb and ub are usedR That is, the first lower bound value and lb L That is, the second lower bound value serves as the lower bound of the size of both sides, which is used to constrain the number of vertices on both sides of each subgraph.
[0046] After obtaining the original bipartite graph, the original bipartite graph G = (L∪R,E), where L is the first vertex set, R is the second vertex set, E is the number of edges, and integers a (defined as a first preset threshold in this embodiment) and b (defined as a second preset threshold in this embodiment) are input into the algorithm to find the target optimal solution, i.e., the maximum (a,b)-biplex, in the original bipartite graph.
[0047] In this embodiment, the overall algorithm framework is as follows: Figure 3 As shown.
[0048] exist Figure 3 The algorithm shown in the diagram first initializes the first and second lower bound values. Then, within a loop, it updates the first and second lower bound values (line 3) and applies a reduction algorithm to the bipartite graph based on these values, resulting in the reduced bipartite graph G' (line 4). Next, it applies the branch and bound method (BRANCH_AND_BOUND) to the reduced bipartite graph G' to find the maximum (a,b)-biplex (line 5), and after the loop completes, it returns the maximum (a,b)-biplex of the original bipartite graph, which is the target subgraph.
[0049] Reference Figure 4 , Figure 4 The algorithm block shown is for Figure 3 A detailed description of the algorithm block shown. First, an empty graph is used to initialize the local optimum. (Line 1), that is, the initial value of the local optimal solution is an empty graph, and the first lower bound value lb is determined by the degree of the vertex with the maximum degree in the first vertex set L. R Initialize by summing the maximum degree of the first vertex and the first preset threshold: (G)+a, the larger of the two numbers, R and the number of the second vertices, is used as the initial value of the first lower bound (line 2). The second lower bound is updated according to the current target optimal solution and the current first lower bound. The second lower bound is affected by the optimal solution and the first lower bound in each iteration. Specifically, the updated second lower bound is the difference between the current local optimal solution and the current first lower bound. The first lower bound is updated to a first value according to a preset rule in each iteration. The first value is less than the current majority of the first lower bound values. In one embodiment, the preset rule can be halving, that is, the first lower bound is halved in each iteration (line 5).
[0050] This step is step S130 shown in the algorithm of the first embodiment. Figure 4 In the seventh row of the algorithm shown in the first embodiment, some vertices in the original bipartite graph are deleted according to the degrees of the first vertices and the second vertices and the first lower bound and the second lower bound, and a reduced bipartite graph is obtained.
[0051] The deleting some vertices in the original bipartite graph according to the degrees of the first vertices and the second vertices and the first lower bound and the second lower bound comprises:
[0052] S210, when the degree of the first vertex is less than a first difference value, the first vertex is deleted from the original bipartite graph, the first difference value being a difference between the first lower bound and a first preset threshold value;
[0053] S220, when the degree of the second vertex is less than a second difference value, the second vertex is deleted from the original bipartite graph, the second difference value being a difference between the second lower bound and a second preset threshold value.
[0054] Specifically, in the original bipartite graph G=(L∪R,E), if there is a first vertex u∈L satisfying deg(u)<lb R -a, the first vertex u does not exist in the (a,b)-biplex with the first lower bound lb R as the lower bound, where deg(u) is the degree of the vertex u. Similarly, if there is a second vertex v∈R satisfying deg(v)<lb L -b, the second vertex v does not exist in the (a,b)-biplex with the second lower bound lb L as the lower bound, where deg(v) is the degree of the vertex v.
[0055] The deleting some vertices in the original bipartite graph according to the degrees of the first vertices and the second vertices and the first lower bound and the second lower bound further comprises:
[0056] S230, when the first neighbor number of the first vertex is less than the second lower bound, the first vertex is deleted from the original bipartite graph, wherein when the common adjacent point number between two first vertices is not less than a third difference value, the two first vertices are the first neighbors of each other, and the third difference value is a difference between the first lower bound and 2 times of the first preset threshold value.
[0057] S240, deleting the second vertex from the original bipartite graph when the second neighbor number of the second vertex is less than the first lower bound value, wherein two second vertices are second neighbors of each other when the common neighbor number between the two second vertices is not less than a fourth difference value, the fourth difference value being the difference between the second lower bound value and 2 times the second preset threshold value.
[0058] Specifically, in the original bipartite graph G=(L∪R,E), if there are two first vertices u1,u2∈L satisfying Δ(u1,u2)≥lb R -2a, it is said that u1 and u2 are first neighbors of each other. Similarly, if there are two second vertices v1,v2∈R satisfying Δ(v1,v2)≥lb L -2b, it is said that v1 and v2 are second neighbors of each other. Here, u1 and u2, v1 and v2 can represent the same vertex.
[0059] In the original bipartite graph G=(L∪R,E), if there is a first vertex u∈L whose first neighbor number is less than the second lower bound value lb L , u does not exist in the (a,b)-biplex with the second lower bound value lb L as the lower bound. Similarly, if there is a vertex v∈R whose second neighbor number is less than the corresponding first lower bound value lb R , v does not exist in the (a,b)-biplex with the first lower bound value lb R as the lower bound.
[0060] Vertices that do not satisfy the above conditions are deleted from the original bipartite graph to obtain a reduced bipartite graph generated in this iteration.
[0061] Referring to Figure 1 , the bipartite graph target subgraph searching method further includes the steps of:
[0062] S300, obtaining a local optimal solution according to the degree of the first vertex and the degree of the second vertex in the reduced bipartite graph, and updating the target optimal solution according to the local optimal solution.
[0063] According to the degree of the first vertex and the degree of the second vertex in the reduced bipartite graph, a local optimal solution is obtained, and the algorithm block diagram of updating the target optimal solution according to the local optimal solution is as follows: Figure 5As shown, the algorithm is a recursive function, which inputs the selected set F, the candidate set U, the first preset threshold a and the first preset threshold b, and the size of the existing solution curbest. The curbest is the local optimal solution. The purpose of the algorithm block is to find the solution with the largest cardinality, so the solution with a size less than curbest will be pruned. The algorithm in lines 1-15 considers the cases when the selected set F is not an (a, b)-biplex, the selected set F and the candidate set U form a larger (a, b)-biplex, the selected set F is larger than the size of the existing solution curbest, and the candidate set U is empty. In lines 17-25, two pruning methods of adding a vertex v in the candidate set U to F and deleting from the branch are proposed based on the inference. The specific implementation based on the two branch methods is described in lines 27-35. The specific implementation steps are as follows:
[0064] S310, add all vertices in the reduced bipartite graph to the candidate set, and set the selected set as an empty set as an initial branch graph.
[0065] Set the initial selected set F as an empty set, and add all vertices in the reduced bipartite graph to the candidate set U. The current selected set F and the current candidate set U form an image as an initial branch graph.
[0066] S320, add a vertex satisfying a first preset condition to the current selected set. The first preset condition is that the vertex and a point not adjacent to the vertex in the current branch graph are first type vertices. The first type vertex is a point satisfying a second preset condition in the current branch graph. The second preset condition is that the first vertex degree is not less than the difference between the number of the second vertex in the current branch graph and the first preset threshold, or the second vertex degree is not less than the difference between the number of the first vertex in the current branch graph and the second preset threshold.
[0067] Specifically, in the current branch graph F∪U=(L i ∪R i ,E i ), if a first vertex u∈L i satisfies deg(u)≥|R i |-a, then u is called a first type point, otherwise a second type point. Similarly, if a second vertex v∈R i satisfies deg(v)≥|L i |-b, then v is called a first type point, otherwise a second type point.
[0068] If the current selected set and the current candidate set In the middle, there is a vertex is the first type point, and all its non-adjacent vertices are the second type point, then the vertex can be directly added to the branch with F as the selected set
[0069] That is, the vertex in the current branch graph that meets the first preset condition is added to the selected set.
[0070] S340, the first vertex or the second vertex meeting the third preset condition is deleted from the current branch graph, the third preset condition is that the number of non-adjacent vertices of the first vertex in the selected set is greater than the first preset threshold, or the number of non-adjacent vertices of the second vertex in the selected set is greater than the second preset threshold.
[0071] Specifically, in the current branch graph F∪U=(L i ∪R i ,E i ), if there is a first vertex u∈L i , the number of non-adjacent vertices in the selected set F is greater than the first preset threshold a, then the first vertex u cannot be added to the branch with F as the selected set, and the first vertex u can be directly deleted from the current branch graph. Similarly, if there is a second vertex v∈R i , the number of non-adjacent vertices in the selected set is greater than the second preset threshold b, then v cannot be added to the branch with F as the selected set, and the second vertex v can be directly deleted from the current branch graph.
[0072] S340, a second type vertex is selected as a root node in each branch graph, the second type vertex is a point that does not meet the second preset condition in the current branch graph, at least one branch is generated according to the set where the root node is located and the selected set is updated, each branch includes a branch graph.
[0073] Among them, the at least one branch is generated according to the set where the root node is located and the selected set is updated, including:
[0074] S321, when the root node is in the selected set, a fifth difference value corresponding to the root node and a target vertex set are obtained, the fifth difference value is the difference between the first preset threshold and the number of non-adjacent vertices of the root node in the selected set, denoted as q, and the target vertex set is a set of non-adjacent vertices of the root node in the selected set;
[0075] S322、according to the fifth difference value and the target vertex set, generating q+1 first branches, in the i-th first branch of the first q first branches, adding the first i-1 vertices of the target vertex set to the selected set, and deleting the i-th vertex from the current branch graph, wherein i is a positive integer not greater than q, in the q+1 first branch, adding the first q vertices of the target vertex set to the selected set, and deleting all the remaining points in the target vertex set from the current branch graph.
[0076] Specifically, in the embodiment, there are two branching rules, wherein the first branching rule is that when the second type point w is in the selected set F, the second type point w is selected as the root node for branching expansion. Without loss of generality, taking the branching based on the first vertex as an example, when w is the first vertex, let wherein a is the first preset threshold, represents the number of vertices of vertex w that have no directly adjacent vertices in the selected set F, represents the number of vertices of vertex w that have no directly adjacent vertices in the selected set F, and it is easy to know that p>q. Let The order of the vertices is not required. Here, q+1 first branches are generated, and i is set to be a positive integer not greater than q:
[0077] The first branch 1: deleting point x1 from the current branch graph, that is, directly deleting point x1 from the current branch graph when i=1;
[0078] The first branch 2 to the first branch q: in the i-th first branch, let the selected set F=F∪{x1,x2,...,x i-1}, add the vertices {x1,x2,...,x i-1} in the selected set to the selected set, and delete x i from the current branch graph.
[0079] The first branch q+1: let the selected set F=F∪{x1,x2,...,x q}, that is, add the vertices {x1,x2,...,x i-1} in the selected set to the selected set, and delete {x q+1 ,x q+2 ,...,x p} from the current branch graph.
[0080] S323, when the root node is in the selected set, generating two second branches, one of which is deleting the root node from the current branch graph, and the other of which is adding the root node to the selected set.
[0081] In the embodiment, the second branching rule is that when there is no second type vertex in the selected set F, the second type vertex w is selected from the candidate set as the root node, and two second branches are generated:
[0082] Second branch 1: the second type vertex w is deleted from the current branching graph.
[0083] Second branch 2: the second type vertex w is added to the current selected set, i.e., F=F∪{w}, and then the branching rule 1 is used to branch.
[0084] S350: the step of adding the vertex satisfying the first preset condition to the current selected set is re-executed until there is no second type vertex in the branching graph, which is set as the target branching graph.
[0085] The step of adding the vertex satisfying the second preset condition to the selected set in the current branching graph is re-executed in the branching graph F∪U generated by all branches, and new branches are continuously generated until there is no second type vertex in the branching graph, which is set as the target branching graph.
[0086] S360: the target branching graph with the largest number of vertices is selected as the local optimal solution.
[0087] In the embodiment, one local optimal solution is generated in each reduced bipartite graph.
[0088] Referring back to Figure 1 In the embodiment, the bipartite graph target subgraph searching method further includes the steps of:
[0089] S400: the steps of updating the first lower bound value and updating the second lower bound value according to the current target optimal solution are re-executed until the first lower bound value is not greater than the minimum preset lower bound, wherein the initial value of the first lower bound value is the sum of the maximum degree of the first vertex and the first preset threshold, and the initial value of the local optimal solution is an empty graph.
[0090] Referring back to Figure 4 , Figure 4 The first lower bound value and the second lower bound value are updated in the 4th-13th rows of the algorithm block iteratively, and the corresponding optimal solution is calculated using the branch and bound method. The second lower bound value lb L In each iteration, the last local optimal solution and the last first lower bound value lb R are affected, wherein the first lower bound value lb Rhalving at each iteration until a preset condition is met, the preset condition being that the first lower bound is not greater than a minimum preset lower bound. In the kth iteration, the current generated local optimal solution and the target optimal solution generated in the last iteration are compared, and the solution with the largest cardinality is selected as the target optimal solution of the current iteration, and returned when the loop stops. Due to the updating rule of the first lower bound in the algorithm, the maximum (a, b)-biplex of the original bipartite graph G is covered by the target optimal solution generated by each iteration. Until the first lower bound is not greater than the minimum preset lower bound, as shown in the algorithm block in the 4th row, the minimum preset lower bound is 1. When the first lower bound is not greater than 1, the iteration ends, and the target optimal solution at this time is the target subgraph to be found in this embodiment. Figure 4
[0091] S500, the latest target optimal solution is taken as the target subgraph, the target subgraph being the subgraph with the largest number of vertices in the subgraph satisfying the target condition in the original bipartite graph, the target condition being that the degree of each first vertex in the subgraph is not less than the difference between the number of second vertices in the subgraph and a first preset threshold, and the degree of each second vertex is not less than the difference between the number of first vertices in the subgraph and a second preset threshold.
[0092] According to the target subgraph found, and the target population and the target content corresponding to each first vertex in the target subgraph and each second vertex, the target population and the target content are obtained, and the target content is recommended to the target population in the platform, so as to realize the product recommendation function.
[0093] In summary, the embodiment provides a method for finding a target subgraph in a bipartite graph, which converts the problem of realizing the product recommendation function according to the corresponding relationship between users and contents in the platform into the problem of finding the maximum (a, b)-biplex of the target subgraph in the original bipartite graph. Thus, the maximum connection relationship between a specific population and a specific content can be found under the given a and b, so as to realize the product recommendation function.
[0094] It should be understood that although each step in the flowchart shown in the drawings of the present application specification is shown in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other sequences. Moreover, at least part of the steps in the flowchart can include multiple sub-steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these sub-steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or sub-steps or stages of other steps.
[0095] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer readable computer readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments of each method. Among them, any reference to memory, storage, database or other medium used in each embodiment provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM) and the like.
[0096] Embodiment two
[0097] Based on the above-mentioned embodiments, the present application also provides a bipartite graph target subgraph searching device, as shown in the figure, the bipartite graph target subgraph searching device comprises: Figure 6
[0098] An initial solution generation module is configured to obtain an original bipartite graph, the original bipartite graph comprising a plurality of first vertices and a plurality of second vertices, wherein any two of the first vertices are not connected to each other, and any two of the second vertices are not connected to each other, and the degrees of the first vertices and the second vertices are obtained, as described in detail in embodiment one.
[0099] A bipartite graph reduction module is configured to update a first lower bound value, update a second lower bound value according to a current target optimal solution, delete part of the vertices in the original bipartite graph according to the degrees of the first vertices and the second vertices and the first lower bound value and the second lower bound value, and obtain a reduced bipartite graph, as described in detail in embodiment one.
[0100] a local optimal solution obtaining module configured to obtain a local optimal solution according to the degree of the first vertex and the degree of the second vertex in the reduced bipartite graph, and update the target optimal solution according to the local optimal solution, as described in detail in Embodiment One;
[0101] an iteration module configured to re-perform the steps of updating the first lower bound value and updating the second lower bound value according to the current target optimal solution until the first lower bound value is not greater than a minimum preset lower bound, wherein the initial value of the first lower bound value is the sum of the maximum degree of the first vertex and the first preset threshold, the initial value of the second lower bound value is the difference between the initial value of the local optimal solution and the initial value of the first lower bound value, and the initial value of the local optimal solution is an empty graph, as described in detail in Embodiment One;
[0102] a subgraph obtaining module configured to take the latest target optimal solution as the target subgraph, the target subgraph being the subgraph with the largest number of vertices in the subgraphs in the original bipartite graph that satisfy a target condition, the target condition being that the degree of each first vertex in a subgraph is not less than the difference between the number of second vertices in the subgraph and the first preset threshold, and the degree of each second vertex is not less than the difference between the number of first vertices in the subgraph and the second preset threshold, as described in detail in Embodiment One.
[0103] Embodiment Three
[0104] Based on the above embodiments, the application also provides a terminal, as shown in Figure 7 The terminal includes a processor 10 and a memory 20. Figure 7 Only some components of the terminal are shown, but it should be understood that all the shown components are not required to be implemented, and more or fewer components can be alternatively implemented.
[0105] The memory 20 can be an internal storage unit of the terminal in some embodiments, such as a hard disk or a memory of the terminal. The memory 20 can also be an external storage device of the terminal in other embodiments, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal. Further, the memory 20 can include both the internal storage unit and the external storage device of the terminal. The memory 20 is used to store application software and various data installed on the terminal. The memory 20 can also be used to temporarily store data that has been output or will be output. In an embodiment, the memory 20 stores a bipartite graph target subgraph searching program 30, which can be executed by the processor 10 to implement the bipartite graph target subgraph searching method.
[0106] The processor 10 can be a central processing unit (CPU), a microprocessor or other chip in some embodiments, which is used to run program codes or process data stored in the memory 20, such as executing the bipartite graph target subgraph searching method.
[0107] In an embodiment, the following steps are implemented when the processor 10 executes the bipartite graph target subgraph searching program 30 in the memory 20:
[0108] An original bipartite graph is obtained, which includes a plurality of first vertices and a plurality of second vertices, wherein any two of the first vertices are not connected to each other, any two of the second vertices are not connected to each other, and the degrees of the first vertices and the second vertices are obtained;
[0109] A first lower bound value is updated, a second lower bound value is updated according to the current target optimal solution, and part of the vertices in the original bipartite graph are deleted according to the degrees of the first vertices and the second vertices and the first lower bound value and the second lower bound value to obtain a reduced bipartite graph;
[0110] A local optimal solution is obtained according to the degrees of the first vertices and the second vertices in the reduced bipartite graph, and the target optimal solution is updated according to the local optimal solution;
[0111] The steps of updating the first lower bound value and updating the second lower bound value according to the current target optimal solution are re-executed until the first lower bound value is not greater than a minimum preset lower bound, wherein the initial value of the first lower bound value is the sum of the maximum degree of the first vertices and the first preset threshold, and the initial value of the local optimal solution is an empty graph;
[0112] the target subgraph is a subgraph in the original bipartite graph that contains the largest number of vertices, and the target condition is that the degree of each first vertex in the subgraph is not less than the difference between the number of second vertices in the subgraph and the first preset threshold, and the degree of each second vertex is not less than the difference between the number of first vertices in the subgraph and the second preset threshold.
[0113] the method further comprises:
[0114] when the degree of the first vertex is less than a first difference value, the first vertex is deleted from the original bipartite graph, the first difference value being the difference between the first lower bound value and the first preset threshold;
[0115] when the degree of the second vertex is less than a second difference value, the second vertex is deleted from the original bipartite graph, the second difference value being the difference between the second lower bound value and the second preset threshold.
[0116] the method further comprises:
[0117] when the number of first neighbors of the first vertex is less than the second lower bound value, the first vertex is deleted from the original bipartite graph, wherein when the number of common adjacent points between two first vertices is not less than a third difference value, the two first vertices are the first neighbors of each other, the third difference value being the difference between the first lower bound value and twice the first preset threshold;
[0118] when the number of second neighbors of the second vertex is less than the first lower bound value, the second vertex is deleted from the original bipartite graph, wherein when the number of common adjacent points between two second vertices is not less than a fourth difference value, the two second vertices are the second neighbors of each other, the fourth difference value being the difference between the second lower bound value and twice the second preset threshold.
[0119] the method further comprises:
[0120] all vertices in the reduced bipartite graph are added to a candidate set, and an empty set is set as a selected set as an initial branch graph;
[0121] adding a vertex satisfying a first preset condition to a current selected set, the first preset condition being that the vertex and vertices not adjacent to the vertex in a current branch graph are all first type vertices, the first type vertex being a vertex satisfying a second preset condition in the current branch graph, the second preset condition being that a first vertex degree is not less than a difference between a second vertex quantity in the current branch graph and a first preset threshold, or a second vertex degree is not less than a difference between a first vertex quantity in the current branch graph and a second preset threshold;
[0122] deleting the first vertex or the second vertex satisfying a third preset condition from the current branch graph, the third preset condition being that a number of vertices not adjacent to the first vertex in the selected set is greater than the first preset threshold, or a number of vertices not adjacent to the second vertex in the selected set is greater than the second preset threshold;
[0123] selecting a second type vertex as a root node in each branch graph, the second type vertex being a vertex not satisfying the second preset condition in the current branch graph, generating at least one branch according to a set in which the root node is located and updating the selected set, each branch including a branch graph;
[0124] re-executing the step of adding a vertex satisfying a first preset condition to a current selected set until there is no second type vertex in the branch graph, and setting the branch graph as a target branch graph;
[0125] selecting a graph with a largest number of vertices as the local optimal solution from all the target branch graphs.
[0126] The generating at least one branch according to the set in which the root node is located and the updating the selected set include:
[0127] when the root node is in the selected set, obtaining a fifth difference value corresponding to the root node and a target vertex set, the fifth difference value being a difference between the first preset threshold and a number of vertices not adjacent to the root node in the selected set, denoted as q, and the target vertex set being a set of vertices not adjacent to the root node in the selected set;
[0128] generating q+1 first branches according to the fifth difference value and the target vertex set, in an i-th first branch of the first q first branches, adding first i-1 vertices of the target vertex set to the selected set and deleting an i-th vertex from a current branch graph, where i is a positive integer not greater than q, and in the q+1 first branch, adding first q vertices of the target vertex set to the selected set and deleting all vertices in the target vertex set from the current branch graph;
[0129] When the root node is in the candidate set, two second branches are generated, one of which is to delete the root node from the reduced bipartite graph, and the other is to add the root node to the selected set.
[0130] The updating the target optimal solution according to the local optimal solution comprises:
[0131] If the local optimal solution is greater than the target optimal solution generated in the last iteration, the local optimal solution is used to replace the target optimal solution generated in the last iteration as the target optimal solution in this time, and if the local optimal solution is less than the target optimal solution generated in the last iteration, the target optimal solution generated in the last iteration is kept as the target optimal solution in this time.
[0132] The updating the first lower bound value comprises updating the first lower bound value to a first value, wherein the first value is less than the current first lower bound value.
[0133] The updating the second lower bound value according to the current target optimal solution comprises:
[0134] The updating the second lower bound value comprises updating the second lower bound value to a difference between a number of vertices in the current target optimal solution and the current first lower bound value.
[0135] Embodiment four
[0136] The application further provides a computer readable storage medium, wherein one or more programs are stored in the computer readable storage medium, and the one or more programs can be executed by one or more processors to implement the steps of the method for searching a target subgraph in a bipartite graph.
[0137] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit the same; even though the above-mentioned embodiments have been described in detail, those skilled in the art should understand that they can still modify the technical solutions recorded in the above-mentioned embodiments, or make equivalent replacements to some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for finding a target subgraph in a bipartite graph, characterized in that, The method comprises: obtaining an original bipartite graph, the original bipartite graph comprising a plurality of first vertices and a plurality of second vertices, wherein any two of the first vertices are not connected to each other, and any two of the second vertices are not connected to each other, obtaining degrees of the first vertices and the second vertices, the original bipartite graph being obtained based on corresponding relationship data of users and contents of one or more platforms, each of the first vertices in the original bipartite graph corresponding to a user in the platform, each of the second vertices in the original bipartite graph corresponding to a content in the platform, and edges in the original bipartite graph being obtained based on an association relationship between the users and the contents in the platform; updating a first lower bound value, updating a second lower bound value according to a current target optimal solution, deleting part of the vertices in the original bipartite graph according to the degrees of the first vertices and the degrees of the second vertices and the first lower bound value and the second lower bound value, and obtaining a reduced bipartite graph; obtaining a local optimal solution according to the degrees of the first vertices and the degrees of the second vertices in the reduced bipartite graph, and updating the target optimal solution according to the local optimal solution; re-executing the steps of updating the first lower bound value and updating the second lower bound value according to the current target optimal solution until the first lower bound value is not greater than a minimum preset lower bound, wherein an initial value of the first lower bound value is a sum of a maximum degree of the first vertices and a first preset threshold, and an initial value of the local optimal solution is an empty graph; taking the latest target optimal solution as the target subgraph, the target subgraph being a subgraph with the largest number of vertices in the original bipartite graph that meets a target condition, and the target condition being that a degree of each of the first vertices in the subgraph is not less than a difference between a number of the second vertices in the subgraph and a first preset threshold, and a degree of each of the second vertices is not less than a difference between a number of the first vertices in the subgraph and a second preset threshold.
2. The method of claim 1, wherein, The step of deleting part of the vertices in the original bipartite graph according to the degrees of the first vertices and the degrees of the second vertices and the first lower bound value and the second lower bound value comprises: when the degree of the first vertex is less than a first difference value, deleting the first vertex from the original bipartite graph, the first difference value being a difference between the first lower bound value and the first preset threshold; when the degree of the second vertex is less than a second difference value, deleting the second vertex from the original bipartite graph, the second difference value being a difference between the second lower bound value and the second preset threshold.
3. The method of claim 1, wherein, The step of deleting part of the vertices in the original bipartite graph according to the degrees of the first vertices and the degrees of the second vertices and the first lower bound value and the second lower bound value further comprises: when a first neighbor number of the first vertex is less than the second lower bound value, deleting the first vertex from the original bipartite graph, wherein when a common neighbor number between two of the first vertices is not less than a third difference value, the two of the first vertices are the first neighbors, and the third difference value is a difference between the first lower bound value and 2 times the first preset threshold. when the second neighbor number of the second vertex is less than the first lower bound value, deleting the second vertex from the original bipartite graph, wherein two second vertices are second neighbors of each other when the number of common adjacent points between the two second vertices is not less than a fourth difference value, the fourth difference value being the difference between the second lower bound value and twice the second preset threshold value.
4. The method of claim 1, wherein, the obtaining the local optimal solution according to the degree of the first vertex and the degree of the second vertex in the reduced bipartite graph comprises: adding all the vertices in the reduced bipartite graph to a candidate set and setting a selected set as an empty set as an initial branch graph; adding a vertex satisfying a first preset condition to a current selected set, the first preset condition being that all the vertices adjacent to the vertex in the current branch graph are first type vertices, the first type vertex being a vertex satisfying a second preset condition in the current branch graph, the second preset condition being that the degree of the first vertex is not less than the difference between the number of second vertices in the current branch graph and the first preset threshold value, or the degree of the second vertex is not less than the difference between the number of first vertices in the current branch graph and the second preset threshold value; deleting the first vertex or the second vertex satisfying a third preset condition from the current branch graph, the third preset condition being that the number of vertices adjacent to the first vertex in the selected set is greater than the first preset threshold value, or the number of vertices adjacent to the second vertex in the selected set is greater than the second preset threshold value; selecting a second type vertex as a root node in each branch graph, the second type vertex being a vertex not satisfying the second preset condition in the current branch graph, generating at least one branch according to the set in which the root node is located and updating the selected set, each branch including a branch graph; re-executing the step of adding a vertex satisfying the first preset condition to the current selected set until there is no second type vertex in the branch graph, the branch graph being set as a target branch graph; selecting a graph with the largest number of vertices from all the target branch graphs as the local optimal solution.
5. The method of claim 4, wherein, the generating at least one branch according to the set in which the root node is located and updating the selected set comprises: when the root node is in the selected set, obtaining a fifth difference value corresponding to the root node and a target vertex set, the fifth difference value being the difference between the first preset threshold value and the number of vertices adjacent to the root node in the selected set, denoted as q, the target vertex set being a set of vertices adjacent to the root node in the candidate set; generating q+1 first branches according to the fifth difference value and the target vertex set, in the i-th first branch among the first q first branches, adding the first i-1 vertices in the target vertex set to the selected set and deleting the i-th vertex from the current branch graph, wherein i is a positive integer not greater than q, and in the q+1-th first branch, adding the first q vertices in the target vertex set to the selected set and deleting all the vertices in the target vertex set from the current branch graph; When the root node is in the candidate set, two second branches are generated, one of which is to delete the root node from the current branch graph, and the other of which is to add the root node to the selected set.
6. The method of Claim 1, wherein, The updating of the target optimal solution according to the local optimal solution comprises: If the local optimal solution is greater than the target optimal solution generated in the last iteration, the local optimal solution is used to replace the target optimal solution generated in the last iteration as the target optimal solution in this time; if the local optimal solution is less than the target optimal solution generated in the last iteration, the target optimal solution generated in the last iteration is retained as the target optimal solution in this time.
7. The method of claim 1, wherein, The updating of the first lower bound value comprises updating the first lower bound value to a first value, wherein the first value is less than the current first lower bound value. The updating of the second lower bound value according to the current target optimal solution comprises: The second lower bound value is updated to the difference between the number of vertices in the current target optimal solution and the current first lower bound value.
8. A device for finding a target subgraph in a bipartite graph, characterized by The method comprises: An initial solution generation module is configured to obtain an original bipartite graph, the original bipartite graph comprising a plurality of first vertices and a plurality of second vertices, wherein any two first vertices are not connected to each other, and any two second vertices are not connected to each other, obtain the degrees of the first vertices and the second vertices, the original bipartite graph being obtained based on user-content correspondence data of one or more platforms, each first vertex in the original bipartite graph corresponding to a user in the platform, each second vertex in the original bipartite graph corresponding to a content in the platform, and the edges in the original bipartite graph being obtained based on the association between the users and the contents in the platform; A bipartite graph reduction module is configured to update a first lower bound value, update a second lower bound value according to a current target optimal solution, delete part of the vertices in the original bipartite graph based on the degrees of the first vertices and the degrees of the second vertices and the first lower bound value and the second lower bound value, and obtain a reduced bipartite graph; A local optimal solution acquisition module is configured to obtain a local optimal solution based on the degrees of the first vertices and the degrees of the second vertices in the reduced bipartite graph, and update the target optimal solution according to the local optimal solution; An iteration module is configured to re-execute the steps of updating the first lower bound value and updating the second lower bound value according to the current target optimal solution until the first lower bound value is not greater than a minimum preset lower bound, wherein the initial value of the first lower bound value is the sum of the maximum degree of the first vertices and a first preset threshold, the initial value of the second lower bound value is the difference between the initial value of the local optimal solution and the initial value of the first lower bound value, and the initial value of the local optimal solution is an empty graph. A subgraph obtaining module is configured to take the latest target optimal solution as the target subgraph, the target subgraph being a subgraph with the largest number of vertices among subgraphs satisfying a target condition in the original bipartite graph, the target condition being that the degree of each first vertex in a subgraph is not less than the difference between the number of second vertices in the subgraph and a first preset threshold, and the degree of each second vertex is not less than the difference between the number of first vertices in the subgraph and a second preset threshold.
9. A terminal, characterized by comprising: The terminal comprises a processor, a computer readable storage medium in communication connection with the processor, the computer readable storage medium being adapted to store a plurality of instructions, and the processor being adapted to invoke the instructions in the computer readable storage medium to perform the steps of the method for searching a target subgraph in a bipartite graph according to any one of the preceding claims.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores one or more programs, and the one or more programs are executable by one or more processors to implement the steps of the method for searching a target subgraph in a bipartite graph according to any one of the preceding claims.