Neighbor graph optimization method and device, computer equipment and readable storage medium
By clustering the candidate data sets and identifying boundary points, a cross-class neighbor graph is generated and fused, which solves the problem that the neighbor graph is prone to falling into local optimality and achieves more accurate nearest neighbor search.
Patent Information
- Application Number
- CN202510716871.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-09-16
AI Technical Summary
Existing neighbor graph construction technologies are prone to falling into local optimal problems and are unable to effectively escape from local optimal solutions, resulting in inaccurate nearest neighbor search results.
By dividing the candidate dataset into multiple target clusters, identifying and generating boundary point sets, establishing cross-class neighbor relationships, fusing the cross-class neighbor graph with the candidate neighbor graph to form a target neighbor graph, and enhancing the connectivity between clusters.
The connectivity of the neighbor graph is improved, enabling it to escape the local optimum during the nearest neighbor search, thus improving the accuracy and efficiency of the search results.
Smart Images

Figure CN120654787A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of nearest neighbor search, and in particular to a nearest neighbor graph optimization method, apparatus, computer equipment, and readable storage medium. Background Art
[0002] Nearest neighbor search is a key technology in the field of unstructured retrieval. It is used to retrieve unstructured data that does not conform to fixed formats or patterns, including text, images, audio, video, log files, and more. Nearest neighbor search generally involves two components: a high-dimensional index and a search algorithm. High-dimensional indexing imparts an organizational order to unstructured data, thereby reducing the complexity of data management and search. The search algorithm, on the other hand, executes the specific search process based on the high-dimensional index structure.
[0003] With the development of the times, high-dimensional indexing technology has evolved into various approaches, including hashing-based methods, spatial partitioning-based methods, quantization-based methods, and neighbor graph-based methods. Among them, neighbor graph technology is currently a prominent approach. It maintains a certain number of neighboring points (neighbors) for each data point in a dataset. A typical neighbor graph structure is the k-nearest neighbor graph, which maintains k neighbors for each data point. When applied to nearest neighbor search, the neighbor graph structure generally follows the principle that "my neighbor's neighbor's neighbor is likely also my neighbor." During the actual search phase of nearest neighbor search, if a query dataset is high-dimensionally indexed using a neighbor graph structure, starting from a random reference point in the query dataset, the algorithm iteratively searches for data points closer to the query point among the neighbors of the reference point, thereby continuously approaching the query point's nearest neighbors and ultimately finding the query point's nearest neighbors in the query dataset.
[0004] Although existing research has proposed a variety of neighbor graph construction techniques, such as KGraph, HNSW (Hierarchical Navigable Small World), ANNOY (Approximate Nearest Neighbors Oh Yeah), and Faiss (Facebook AI Similarity Search), none of these methods effectively address an inherent drawback of neighbor graph construction: the tendency to fall into local optimality. Summary of the Invention
[0005] In view of this, one or more embodiments of the present disclosure provide a neighbor graph optimization method, apparatus, computer equipment and readable storage medium, which can effectively improve the connectivity of the neighbor graph and ensure that the improved neighbor graph has the ability to escape the local optimum when used for nearest neighbor search.
[0006] On the one hand, the present disclosure provides a neighbor graph optimization method, which includes: dividing a candidate data set into multiple target clusters, any target cluster consisting of several data points of the candidate data set; determining the boundary points of each target cluster, and generating a boundary point set based on the boundary points; identifying a cross-class neighbor relationship between a first boundary point and a second boundary point in the boundary point set, and generating a cross-class neighbor graph based on the cross-class neighbor relationship, wherein the first boundary point and the second boundary point belong to different target clusters; fusing the cross-class neighbor graph with the candidate neighbor graph to form a target neighbor graph, wherein the candidate neighbor graph is pre-generated based on the candidate data set.
[0007] On the other hand, the present disclosure also provides a neighbor graph optimization device, which includes: a cluster identification unit, which is used to divide a candidate data set into multiple target clusters, and any target cluster is composed of several data points of the candidate data set; a boundary identification unit, which is used to determine the boundary points of each target cluster, and generate a boundary point set based on the boundary points; an image generation unit, which is used to identify the cross-class neighbor relationship between the first boundary point and the second boundary point in the boundary point set, and generate a cross-class neighbor graph based on the cross-class neighbor relationship, and the first boundary point and the second boundary point belong to different target clusters; an image fusion unit, which is used to fuse the cross-class neighbor graph with the candidate neighbor graph to form a target neighbor graph, and the candidate neighbor graph is pre-generated based on the candidate data set.
[0008] On the other hand, the present disclosure further provides a computer device, which includes a memory and a processor, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the above-mentioned neighbor graph optimization method is implemented.
[0009] On the other hand, the present disclosure further provides a computer-readable storage medium, which is used to store a computer program. When the computer program is executed by a processor, it implements the above-mentioned neighbor graph optimization method.
[0010] The technical solution provided by one or more embodiments of the present disclosure first uses clustering technology to identify the target clusters in the candidate data set. Then, the boundary points of each target cluster are found to form a boundary point set. Using the boundary point set, the cross-class neighbor relationship between the first boundary point and the second boundary point can be identified to generate a cross-class neighbor graph. Since the cross-class neighbor graph contains the cross-class neighbor paths between each target cluster, the cross-class neighbor graph is merged with the pre-generated candidate neighbor graph, and the target neighbor graph obtained can have the ability to jump out of the local optimum. In other words, by using the improved target neighbor graph to perform nearest neighbor search, it is possible to start from the reference point, flexibly cross different target clusters in the data set to be queried, and accurately find the nearest neighbors of the query point.
[0011] The technical solution provided by one or more embodiments of the present disclosure is a general neighbor graph optimization technique that is not tied to a specific neighbor graph construction technology. In theory, the technical solution provided by one or more embodiments of the present disclosure can be used to optimize candidate neighbor graphs generated by any neighbor graph construction technology (such as KGraph, HNSW, etc.). BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The features and advantages of the various embodiments of the present disclosure will be more clearly understood by referring to the accompanying drawings, which are schematic and should not be construed as limiting the present disclosure in any way. In the accompanying drawings:
[0013] Figure 1 A schematic diagram showing a scenario state in which the nearest neighbor search in the related art falls into a local optimum problem;
[0014] Figure 2 A schematic diagram showing the steps of a neighbor graph optimization method in one embodiment of the present disclosure is shown;
[0015] Figure 3 A schematic diagram showing the application effect of the neighbor graph optimization method in one embodiment of the present disclosure is shown;
[0016] Figure 4 A schematic diagram of the functional modules of a neighbor graph optimization judgment device in one embodiment of the present disclosure is shown;
[0017] Figure 5 A schematic structural diagram of a computing device in one embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0018] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0019] Among related technologies, KGraph and HNSW are two relatively prominent neighbor graph construction technologies. However, neighbor graphs constructed based on KGraph or HNSW often still suffer from a typical flaw: they are prone to falling into local optimality.
[0020] In related technologies, the main reason for the local optimal problem comes from the complexity of the distribution of data points in the actual feature data set. In a practical application scenario, please refer to Figure 1 , the distribution characteristics of a part of the data points in an actual data set can be expressed by Figure 1As you can see, these data points form two clusters. The data points within the same cluster are very close, but the data points between clusters are far apart.
[0021] Figure 1 A 2-nearest neighbor graph is constructed on this dataset, that is, each data point can point to two nearest neighbors. Figure 1 , which explains why the nearest neighbor search on this 2-nearest neighbor graph will fall into the local optimal problem.
[0022] exist Figure 1 In the query point, q represents a query point. The nearest neighbor search begins with a random data point A as the reference point. First, the distances from A's two neighbors to q are calculated. It is found that data point B is closer to q. Therefore, the reference point is moved to B. This process is repeated until no point closer to q can be found among the neighbors of the reference point. The search stops, and the current reference point is returned as the final result of the nearest neighbor search.
[0023] according to Figure 1 , the reference points that the search path passes through in sequence are A, B, C and D. Eventually, it is found that the distances from D's neighbors to q are all greater than D. Therefore, the search stops and D is returned as the final result of the nearest neighbor search. However, it is obvious that Figure 1 The real nearest neighbor of q should be F instead of D. However, due to the local distribution characteristics of data points, the distance between the two clusters is far, resulting in no edge from data point D to the right cluster when the neighbor graph is generated (each edge corresponds to Figure 1 A line in can represent the neighbor connection relationship between two data points), so the reference point cannot go to F.
[0024] The above is a typical example of the local optimal problem of the neighbor graph. Figure 1 It can be seen that the main reason for the local optimal problem is that there is no connection between clusters.
[0025] In view of this, the technical solutions provided by one or more embodiments of the present disclosure can effectively improve the connectivity of the neighbor graph, ensuring that the improved neighbor graph can escape local optima when used for nearest neighbor search. A key innovation of the technical solutions provided by one or more embodiments of the present disclosure is to find a way to establish connections between clusters.
[0026] It should be noted that the technical solutions provided in one or more embodiments of this disclosure are not standalone neighbor graph construction techniques. Instead, they assume that the user has already constructed a neighbor graph. Based on this, the technical solutions provided by this disclosure can further enhance the cluster connectivity of the neighbor graph and optimize its performance when used for nearest neighbor searches.
[0027] See also Figure 2 , a neighbor graph optimization method provided by one embodiment of the present disclosure may include the following steps.
[0028] S1: Divide the candidate data set into multiple target clusters, where any target cluster is composed of several data points of the candidate data set.
[0029] In this embodiment, if an already constructed neighborhood graph (i.e., a pre-generated candidate neighborhood graph) needs to be optimized, the dataset corresponding to the candidate neighborhood graph, i.e., the candidate dataset, can be first obtained. Based on this, data processing and image processing can be performed to achieve the goal of optimizing the candidate neighborhood graph.
[0030] In this embodiment, each data point in the candidate dataset can be represented by a feature vector, corresponding to a set of unstructured data. Unstructured data is often difficult to process using traditional database management systems due to its diverse forms, including text, images, audio, video, log files, and so on. Feature extraction is a common method for managing and retrieving unstructured data. For example, in the field of face recognition, key points such as the corners of the eyes, the corners of the mouth, the chin, and the distance between the eyes can be identified from a facial image. Each of these features is called a feature dimension and can be represented by a numerical value. All feature dimensions combined form a feature vector. Since it is a vector, distance can be measured. If two images are very similar, the distance between their feature vectors (usually the Euclidean distance) is often small; otherwise, the distance will be large. It is worth noting that feature vectors extracted using the same feature extraction method typically have the same dimension, which can be represented by d. Clearly, each d-dimensional feature vector can be viewed as a point in d-dimensional space. Thus, the problem of unstructured data retrieval is transformed into a nearest neighbor search problem in d-dimensional space. As can be seen, in the field of nearest neighbor search technology, feature vectors and feature data points are effectively the same concept.
[0031] In this embodiment, the candidate data set is divided into multiple target clusters, which can be achieved through some clustering algorithms, such as partition clustering, hierarchical clustering, density clustering, model clustering, grid clustering, etc.
[0032] It should be noted that different clustering algorithms may differ in clustering accuracy and efficiency. However, as long as multiple target clusters can be formed, the subsequent steps of the method provided by this disclosure can be continued to enhance the connectivity between different clusters and ensure that the improved neighbor graph has the ability to escape local optima when used for nearest neighbor search. In other words, using different clustering algorithms to divide the candidate dataset can achieve the goal of optimizing the neighbor graph; the only difference lies in the different optimization effects.
[0033] In some embodiments, dividing the candidate data set into multiple target clusters includes: randomly selecting a target number of data points as initial cluster centroids within the set range of the candidate data set; associating each candidate data point to the nearest centroid based on the distance from each candidate data point of the candidate data set to each cluster centroid to form a target number of clusters; updating the cluster centroid corresponding to the cluster based on the statistical mean of the candidate data points contained in each cluster; iteratively updating the cluster centroids and the clusters until the maximum number of iterations is reached or the cluster centroids no longer change; and determining the cluster after the iteration is completed as the target cluster.
[0034] Specifically, the target number can be user-defined, can be selected by the user within a reasonable value range based on historical patterns, or can be pre-analyzed and evaluated (for example, for the KMeans clustering algorithm, the elbow rule is used to determine the optimal number of clusters).
[0035] By randomly selecting the initial cluster centroid, the clustering process can be quickly initiated, providing a foundation for subsequent iterative optimization. In each iteration, clusters are divided based on the distance between the data points and the centroid. This method is simple, intuitive, and computationally efficient, making it particularly suitable for processing large-scale data sets. At the same time, by updating the centroid using the statistical mean, the clustering results can be gradually optimized, making the data points within the cluster closer and the distinction between clusters more distinct, thereby improving the accuracy and stability of the clustering. In addition, setting the maximum number of iterations or the centroid no longer changing as the stopping condition not only ensures the convergence of the algorithm, but also avoids excessive calculations, improving the practicality and efficiency of the algorithm.
[0036] S2: Determine the boundary points of each target cluster, and generate a boundary point set based on the boundary points.
[0037] In this embodiment, data points within a target cluster can be divided into two types based on their location attributes: those located within the target cluster and those located outside it. The latter can be referred to as "boundary points." If connections can be established between these boundary points, paths across clusters can be constructed, thereby resolving the local optimality problem in the neighborhood graph.
[0038] In some embodiments, determining the boundary points of each target cluster includes: traversing each target cluster; for a current cluster in the target cluster, traversing each data point of the current cluster; for a current data point in the current cluster, determining the data point in the current cluster that is farthest from the current data point as a boundary point of the current cluster.
[0039] Specifically, we traverse each target cluster and its data points, and using each data point as a benchmark, we find the point in the same cluster that is farthest away from it as a boundary point, which can accurately determine the boundaries of each cluster. This method can effectively capture the shape and scope of clusters, and is particularly advantageous when dealing with irregularly shaped clusters.
[0040] In a practical application example, let M represent a set for collecting the boundary points of all target clusters, and initialize Assuming there are c target clusters in total, the process of collecting boundary points is as follows: let i = 1; if i ≤ c, then for each point x in the i-th cluster, search for the point f farthest from x in the i-th cluster and add f to M; after processing the i-th cluster, let i = i + 1.
[0041] S3: Identify a cross-class neighbor relationship between a first boundary point and a second boundary point in the boundary point set, and generate a cross-class neighbor graph based on the cross-class neighbor relationship, where the first boundary point and the second boundary point belong to different target clusters.
[0042] In this embodiment, by identifying the cross-class neighbor relationships between the boundary points of different target clusters, a cross-class neighbor graph can be constructed to reveal the close areas and potential correlations between target clusters, thereby enhancing the connectivity between different clusters.
[0043] In some embodiments, identifying the cross-class neighbor relationship between the first boundary point and the second boundary point in the boundary point set includes: determining any data point in the boundary point set as the first boundary point; removing the first boundary point and the data points belonging to the same target cluster as the first boundary point from the boundary point set to obtain a cross-class point set; and identifying the second boundary point in the cross-class point set that has a neighbor relationship with the first boundary point.
[0044] Specifically, a boundary point is first identified as the first boundary point. Then, points belonging to the same cluster as the first boundary point are removed from the boundary point set to form a cross-cluster point set. Finally, a second boundary point that is a neighbor of the first boundary point is found within the cross-cluster point set. This method effectively avoids searching for neighbor points within the same cluster and focuses directly on the neighbor point relationships between different clusters. This allows for rapid and accurate identification of cross-cluster neighbor relationships, helping to efficiently reveal potential connections and boundary features between clusters.
[0045] To find a second boundary point that has a neighbor relationship with the first boundary point in the cross-class point set, some neighbor analysis algorithms (such as KGraph algorithm, HNSW algorithm, etc.) can be used to capture the neighbor relationship between the first boundary point and the second boundary point.
[0046] In some embodiments, generating a cross-class neighbor graph based on the cross-class neighbor relationship includes: establishing a cross-class neighbor edge between the first boundary point and the second boundary point based on the cross-class neighbor relationship; and generating the cross-class neighbor graph according to the boundary point set and the cross-class neighbor edge.
[0047] Specifically, by establishing cross-class neighbor edges to generate a cross-class neighbor graph, we can intuitively display the neighbor relationships between points at the boundaries of different clusters. This transforms complex cluster adjacency into a visual graph structure, making it easier to clearly understand the global distribution and local connectivity characteristics of data points.
[0048] S4: Fusing the cross-class neighbor graph with the candidate neighbor graph to form a target neighbor graph, where the candidate neighbor graph is pre-generated based on the candidate data set.
[0049] In this embodiment, the target neighbor graph is formed by fusing the cross-class neighbor graph with the candidate neighbor graph, integrating the neighbor relationship information of the two images. This fusion not only preserves the neighbor structure within the clusters reflected by the candidate neighbor graph, but also introduces the neighbor relationships between clusters reflected by the cross-class neighbor graph, thereby providing a more comprehensive and richer view of data point connectivity. The target neighbor graph can more accurately reflect the overall structure and local characteristics of the data points. Using the target neighbor graph for nearest neighbor search can enable the ability to escape local optima.
[0050] In some embodiments, the fusion of the cross-class neighbor graph and the candidate neighbor graph to form a target neighbor graph includes: identifying overlapping data points of the cross-class neighbor graph and the candidate neighbor graph; in the candidate neighbor graph, for any of the overlapping data points, deleting the first number of neighbor edges connecting the overlapping data points to obtain the expected neighbor graph; and fusing the expected neighbor graph with the cross-class neighbor graph to generate the target neighbor graph.
[0051] Specifically, the target neighbor graph is generated by identifying overlapping data points in the cross-class neighbor graph and the candidate neighbor graph, removing some of the neighbor edges connecting the overlapping data points in the candidate neighbor graph, and then fusing it with the cross-class neighbor graph. This processing method effectively reduces redundant edges and avoids information duplication, while preserving key cross-class connections. This makes the target neighbor graph more concise and informative, helping to more clearly demonstrate the complex relationships between data points.
[0052] In some embodiments, any data point of the candidate neighbor graph pre-contains a second number of neighbor edges, and the first number is smaller than the second number.
[0053] Specifically, only a portion (a first number) of the existing neighbor edges in the candidate neighbor graph are deleted, ensuring that the basic connectivity structure of the data points is preserved during the image fusion process. This design reduces redundant information while avoiding excessive sparsity, ensuring that key connectivity relationships between data points are not destroyed. The resulting target neighbor graph can thus more accurately reflect the overall structure and local characteristics of the data, improving its quality and reliability.
[0054] In some embodiments, if the second number is an even number, the first number is equal to half of the second number; if the second number is an odd number, the first number is equal to half of the second number minus 1. For example, if the second number is k, if k is an even number, the first number is k / 2; if k is an odd number, the first number is (k-1) / 2.
[0055] Specifically, the first number is set to half (or close to half) of the second number, which uniquely limits the number of deleted neighbor edges. This selection method provides a balanced strategy when processing data fusion. Compared with schemes such as the first number being 1 / 3 of the second number, the first number being 1 / 4 of the second number, or the first number being a fixed value, it can not only significantly reduce redundant information, but also retain sufficient connectivity to maintain the basic structure between data points. In addition, this neighbor edge deletion method is also an adaptive mechanism with flexibility that can adapt to various practical application scenarios.
[0056] See also Figure 3 , a neighbor graph optimization method provided by one embodiment of the present disclosure can be implemented through the following process.
[0057] Step 1: Use KMeans to generate c clusters (c is set by the user) for the candidate dataset O. It should be noted that the candidate dataset O has already generated a candidate neighbor graph P in advance, and P is a k-nearest neighbor graph.
[0058] Step 2: Let M represent a set, collect the boundary points of all clusters found next, and initialize
[0059] Step 3: Let i=1.
[0060] Step 4: If i≤c, go to step 5; otherwise, go to step 7.
[0061] Step 5. For each point x in cluster C_i, search for x's farthest neighbor f in C_i (i.e., the point farthest from x in C_i), and add f to M. It should be noted that when adding M, the cluster from which each point comes should also be recorded for easy use in the subsequent step 7.
[0062] Step 6: i=i+1, go to step 4.
[0063] Step 7. Apply the KGraph algorithm to M to generate a k / 2-nearest neighbor graph P', where each data point in P' has k / 2 edges pointing to its k / 2 nearest neighbors across clusters. When using KGraph here, a small adjustment is required: when searching for the nearest neighbors of each point x∈M, first exclude the points in M that are from the same cluster as x. If this is not done, it is very likely that an edge of x in P' will point to a point from the same cluster as x, which is meaningless for crossing clusters (refer to Figure 3 (red dashed line in ).
[0064] Step 8: Merge P' into P, ensuring that P remains a k-nearest neighbor graph. Specifically, for each point x in P' that overlaps with P, first delete the last k / 2 (relatively distant) nearest neighbors of x in P. Then, add x's k / 2 cross-class neighbors in P' to P. At this point, x in P still has only k edges.
[0065] By constructing a cross-cluster neighbor graph for cluster boundary points separately, a path across clusters can be constructed to solve problems similar to the above Figure 1 The local optimal problem in . Figure 3 As shown, by using the neighbor graph optimization method provided by this disclosure to improve the connectivity of the candidate neighbor graph, when the search reaches D, a point E closer to the query point q will be found among D's neighbors, thus continuing to move closer to q. Ultimately, through the connected paths within the cluster on the right, it is possible to find the true nearest neighbor F of the query point q.
[0066] The technical solution provided by one or more embodiments of the present disclosure first uses clustering technology to identify the target clusters in the candidate data set. Then, the boundary points of each target cluster are found to form a boundary point set. Using the boundary point set, the cross-class neighbor relationship between the first boundary point and the second boundary point can be identified to generate a cross-class neighbor graph. Since the cross-class neighbor graph contains the cross-class neighbor paths between each target cluster, the cross-class neighbor graph is merged with the pre-generated candidate neighbor graph, and the target neighbor graph obtained can have the ability to jump out of the local optimum. In other words, by using the improved target neighbor graph to perform nearest neighbor search, it is possible to start from the reference point, flexibly cross different target clusters in the data set to be queried, and accurately find the nearest neighbors of the query point.
[0067] The technical solution provided by one or more embodiments of the present disclosure is a general neighbor graph optimization technique that is not tied to a specific neighbor graph construction technology. In theory, the technical solution provided by one or more embodiments of the present disclosure can be used to optimize candidate neighbor graphs generated by any neighbor graph construction technology (such as KGraph, HNSW, etc.).
[0068] See also Figure 4The present disclosure further provides a neighbor graph optimization device, the device comprising:
[0069] A cluster identification unit 100 is configured to divide the candidate dataset into a plurality of target clusters, wherein any target cluster is composed of a plurality of data points of the candidate dataset;
[0070] A boundary identification unit 200 is used to determine the boundary points of each target cluster and generate a boundary point set based on the boundary points;
[0071] An image generating unit 300 is configured to identify a cross-class neighbor relationship between a first boundary point and a second boundary point in the boundary point set, and generate a cross-class neighbor graph based on the cross-class neighbor relationship, wherein the first boundary point and the second boundary point belong to different target clusters;
[0072] The image fusion unit 400 is configured to fuse the cross-class neighbor graph with a candidate neighbor graph to form a target neighbor graph, where the candidate neighbor graph is pre-generated based on the candidate dataset.
[0073] In one embodiment, the boundary identification unit 200 is specifically used to traverse each of the target clusters; for the current cluster in the target cluster, traverse each data point of the current cluster; for the current data point of the current cluster, determine the data point in the current cluster that is farthest from the current data point as a boundary point of the current cluster.
[0074] In one embodiment, the image generation unit 300 is specifically used to determine any data point in the boundary point set as the first boundary point; in the boundary point set, eliminate the first boundary point and the data points belonging to the same target cluster as the first boundary point to obtain a cross-class point set; identify the second boundary point in the cross-class point set that has a neighboring relationship with the first boundary point.
[0075] In one embodiment, the image generation unit 300 is further used to establish a cross-class neighbor edge between the first boundary point and the second boundary point based on the cross-class neighbor relationship; and generate the cross-class neighbor graph according to the boundary point set and the cross-class neighbor edge.
[0076] In one embodiment, the image fusion unit 400 is specifically used to fuse the cross-class neighbor graph with the candidate neighbor graph to form a target neighbor graph, including: identifying overlapping data points of the cross-class neighbor graph and the candidate neighbor graph; in the candidate neighbor graph, for any of the overlapping data points, deleting the first number of neighbor edges connecting the overlapping data points to obtain the expected neighbor graph; fusing the expected neighbor graph with the cross-class neighbor graph to generate the target neighbor graph.
[0077] In one embodiment, any data point of the candidate neighbor graph pre-contains a second number of neighbor edges, and the first number is smaller than the second number.
[0078] In one embodiment, the cluster identification unit 100 is specifically used to randomly select a target number of data points as initial cluster centroids within the set range of the candidate data set; associate each candidate data point to the nearest centroid based on the distance from each candidate data point in the candidate data set to each cluster centroid to form a target number of clusters; update the cluster centroid corresponding to the cluster based on the statistical mean of the candidate data points contained in each cluster; iteratively update the cluster centroid and the cluster cluster until the maximum number of iterations is reached or the cluster centroid no longer changes; and determine the cluster cluster after the iteration is completed as the target cluster.
[0079] The various units described in the above embodiments can be implemented by computer chips or products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0080] For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing this application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0081] See also Figure 5 The present disclosure also provides a computer device, which includes a memory and a processor, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the above-mentioned neighbor graph optimization method is implemented.
[0082] The present disclosure also provides a computer-readable storage medium, which is used to store a computer program. When the computer program is executed by a processor, it implements the above-mentioned neighbor graph optimization method.
[0083] The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.
[0084] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as the program instructions / modules corresponding to the methods in the embodiments of the present disclosure. The processor executes the non-transitory software programs, instructions, and modules stored in the memory to perform various processor functions and data processing, thereby implementing the methods in the aforementioned method embodiments.
[0085] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory may optionally include a memory remotely located relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0086] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD). The storage medium can also include a combination of the above-mentioned types of memory.
[0087] The various embodiments in this specification are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from the other embodiments. In particular, the device, equipment, and storage medium embodiments are generally similar to the method embodiments, so their descriptions are relatively simplified. For relevant portions, refer to the descriptions of the method embodiments.
[0088] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.
[0089] In the description of this application, the terms "comprises," "comprising," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. The terms "first," "second," and the like in this application are used to distinguish similar objects and are not used to describe a particular order or precedence.
[0090] Although the embodiments of the present disclosure have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A nearest neighbor graph optimization method, characterized in that: The method comprises: Dividing the candidate dataset into a plurality of target clusters, wherein any of the target clusters is composed of a plurality of data points of the candidate dataset; Determining boundary points of each of the target clusters, and generating a boundary point set based on the boundary points; Identifying a cross-class neighbor relationship between a first boundary point and a second boundary point in the boundary point set, and generating a cross-class neighbor graph based on the cross-class neighbor relationship, wherein the first boundary point and the second boundary point belong to different target clusters; The cross-class neighbor graph and the candidate neighbor graph are fused to form a target neighbor graph, where the candidate neighbor graph is pre-generated based on the candidate dataset.
2. The method according to claim 1, characterized in that Determining the boundary points of each target cluster includes: Traversing each of the target clusters; For a current cluster in the target cluster, traverse each data point of the current cluster; For a current data point of the current cluster, a data point in the current cluster that is farthest from the current data point is determined as a boundary point of the current cluster.
3. The method according to claim 1, characterized in that The identifying a cross-class neighbor relationship between a first boundary point and a second boundary point in the boundary point set includes: Determine any data point in the boundary point set as the first boundary point; Eliminate the first boundary point and data points belonging to the same target cluster as the first boundary point from the boundary point set to obtain a cross-class point set; Identify the second boundary point in the cross-class point set that has a neighbor relationship with the first boundary point.
4. The method according to claim 3, characterized in that Generating a cross-class neighbor graph based on the cross-class neighbor relationship includes: Based on the cross-class neighbor relationship, establishing a cross-class neighbor edge between the first boundary point and the second boundary point; The cross-class neighbor graph is generated according to the boundary point set and the cross-class neighbor edges.
5. The method according to claim 1, wherein The fusing of the cross-class neighbor graph and the candidate neighbor graph to form a target neighbor graph includes: Identifying overlapping data points between the cross-class nearest neighbor graph and the candidate nearest neighbor graph; In the candidate neighbor graph, for any of the overlapping data points, a first number of neighbor edges connecting the overlapping data points are deleted to obtain a desired neighbor graph; The desired neighbor graph and the cross-class neighbor graph are fused to generate the target neighbor graph.
6. The method according to claim 5, characterized in that Any data point of the candidate neighbor graph pre-contains a second number of neighbor edges, and the first number is smaller than the second number.
7. The method according to claim 1, characterized in that The candidate data set is divided into multiple target clusters, including: Randomly select a target number of data points as initial cluster centroids within the set of candidate data sets; According to the distance between each candidate data point in the candidate data set and each cluster centroid, each candidate data point is associated with the nearest centroid to form a target number of clusters; Update the cluster centroid corresponding to the cluster according to the statistical mean of the candidate data points contained in each cluster; Iteratively updating the cluster centroid and the cluster cluster until a maximum number of iterations is reached or the cluster centroid no longer changes; The cluster after the iteration is completed is determined as the target cluster.
8. A neighbor graph optimization device, characterized in that: The device comprises: a cluster identification unit, configured to divide the candidate dataset into a plurality of target clusters, wherein any of the target clusters is composed of a plurality of data points of the candidate dataset; a boundary identification unit, configured to determine boundary points of each of the target clusters and generate a boundary point set based on the boundary points; an image generating unit, configured to identify a cross-class neighbor relationship between a first boundary point and a second boundary point in the boundary point set, and generate a cross-class neighbor graph based on the cross-class neighbor relationship, wherein the first boundary point and the second boundary point belong to different target clusters; An image fusion unit is used to fuse the cross-class neighbor graph with a candidate neighbor graph to form a target neighbor graph, where the candidate neighbor graph is pre-generated based on the candidate data set.
9. A computer device, characterized in that: The computer device includes a memory and a processor, the memory is used to store a computer program, and when the computer program is executed by the processor, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.