An attribute graph clustering method and device based on contrast learning, and a medium

By reconstructing the attribute adjacency matrix using the K-nearest neighbor algorithm and Laplace filter, and combining dual encoders and modularity maximization loss, the noise interference problem caused by attribute-topology inconsistency in existing graph clustering methods is solved, achieving high-quality multi-granularity clustering results.

CN123158271APending Publication Date: 2026-11-24ZHENGZHOU UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202611430549.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-15
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

Existing graph clustering methods based on contrastive learning are susceptible to noise interference from attribute-topology inconsistencies, resulting in a severe decline in clustering quality. Furthermore, they lack multi-granularity modeling and cannot integrate local, meso-, and macro-structures.

Method used

The attribute adjacency matrix is ​​reconstructed using the K-nearest neighbor algorithm based on node attributes. Graph optimization is then performed using a Laplace filter. A dual encoder design and modularity maximization loss are employed to achieve comparative learning at the node and cluster levels, collaboratively optimizing local consistency, meso-cluster semantics, and macro-community structure.

Benefits of technology

It significantly suppresses noise caused by attribute-topological inconsistency, improves clustering quality, increases the resolution of cluster centers and the accuracy of clustering results, and meets the needs of community detection in practical applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123158271A_ABST
    Figure CN123158271A_ABST
Patent Text Reader

Abstract

This invention belongs to the field of graph clustering technology, specifically relating to an attribute graph clustering method, apparatus, and medium based on contrastive learning. The method includes: S1) obtaining the node attribute matrix and the original adjacency matrix of the attribute graph to be clustered; S2) for each node, selecting the K nearest nodes in the attribute space as its attribute neighbors, and constructing an attribute adjacency matrix based on these neighbors; then, fusing the attribute adjacency matrix and the original adjacency matrix to obtain an enhanced adjacency matrix; S3) constructing a Laplace filter based on the enhanced adjacency matrix, and filtering the node attribute matrix using the Laplace filter to obtain a smoothed node attribute matrix; S4) performing clustering based on the smoothed node attribute matrix. This invention solves the technical problem that existing graph clustering methods based on contrastive learning are susceptible to noise interference from attribute-topology inconsistencies, resulting in a severe deterioration in clustering quality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of graph clustering technology, specifically relating to an attribute graph clustering method, apparatus, and medium based on contrastive learning. Background Technology

[0002] Graph clustering (also known as community detection) is a fundamental unsupervised learning task that aims to divide a network into several subgroups (communities) with dense internal connections and sparse external connections. With the rapid development of Graph Convolutional Networks (GCNs), attribute graph clustering, which utilizes both node attribute features and topological structure for clustering, has become a key technique for analyzing complex network data. In practical applications, attribute graphs are widely present in real life. For example, in citation networks, each paper contains both textual content as an attribute description and citation relationships representing topological connections; in social networks, each user has both personal characteristics equivalent to attributes and social relationships corresponding to the topology; in biological networks, each protein has both sequence features (attributes) and interaction relationships (topology). How to effectively integrate these two types of information for high-quality unsupervised clustering is one of the core problems in the field of graph data mining. Most existing attribute graph clustering methods fall into the following categories:

[0003] (1) Traditional methods: such as spectral clustering, non-negative matrix factorization (NMF), and Louvain's algorithm. Among them, spectral clustering uses Laplacian matrix eigenvalue decomposition and calculates complexity, but it is difficult to extend to large-scale graphs; NMF can utilize topological structure but ignores node attributes, making it difficult to deeply mine the deep features of graph data; Louvain's algorithm has a limit to resolution and also ignores attribute information. These traditional methods perform poorly when dealing with modern large-scale attribute graphs.

[0004] (2) Deep Generative Methods: In recent years, deep learning-based graph clustering methods have emerged, such as Graph Auto-Encoder (GAE), Variational Graph Auto-Encoder (VGAE), Marginalized Graph Auto-Encoder (MGAE), Deep Attributed Graph Clustering (DAEGC), Adversarially Regularized Graph Auto-Encoder (ARGA), Structural Deep Clustering Network (SDCN), and Deep Fusion Clustering Network (DFCN). These methods map graphs to the latent space through graph convolutional encoders or introduce techniques such as denoising mechanisms, attention networks, and adversarial regularization to learn representations. However, these methods share a common drawback: they heavily rely on the accurate initialization of cluster centers, usually requiring a cumbersome pre-training phase, resulting in low computational efficiency and a tendency to get trapped in local optima.

[0005] (3) Contrastive learning methods: To overcome the dependence on cluster center initialization, contrastive learning-based methods such as Graph Contrastive Learning (GraphCL), Multi-View Graph Representation Learning (MVGRL), Self-supervised Contrastive Attributed Graph Clustering (SCAGC), Contrastive Clustering Graph Convolutional Network (CCGC), and Self-supervised Graph Clustering (SCGC) have emerged. However, existing contrastive learning methods still have two key drawbacks: first, they rely on the original topology and features, making them susceptible to noise interference from attribute-topology inconsistencies; second, they lack multi-granularity modeling and cannot integrate local-meso-macro structures.

[0006] For example, the Chinese invention patent application with publication number CN117036760A and publication date of November 10, 2023, discloses a method for implementing a multi-view clustering model based on graph contrastive learning. This method utilizes contrastive learning techniques to further enhance node embedding and make similar nodes closer in low-dimensional space, thus making subsequent clustering tasks more accurate. It also introduces a self-supervised module to assist the clustering task and uses soft labels to supervise the graph clustering process, thereby improving the model's generalization ability. However, it lacks macroscopic community structure constraints, and the learned partitions lack macroscopic topological cohesion, failing to meet the needs of community discovery in practical applications.

[0007] The paper "Revisiting Modularity Maximization for Graph Clustering: A Contrastive Learning Perspective" published by Yunfei Liu et al. in 2024 and accepted by ACM SIGKDD 2024 discloses a graph clustering framework called MAGI. MAGI uses modularity maximization as a pre-text task of contrastive learning, but adopts a two-stage training method and does not achieve end-to-end joint optimization of graph optimization, multi-granularity contrastive learning and modularity.

[0008] Chinese invention patent application CN117875401A, published on April 12, 2024, discloses a system and method for implementing a graph contrastive learning model based on community information. This method involves edge diffusion or random addition and deletion of edges in the original graph structure, and random masking of node attributes. Then, subsampled subgraphs are encoded using a shared-parameter encoder to obtain node representations of the local and global enhanced attribute graph views. The graph encoder then uses a combined loss of node-level and cluster-level contrastive losses and modularity maximization as its loss. This method performs dual contrastive analysis at both the node and cluster levels and introduces modularity maximization, effectively capturing the high-order community structure of the network. However, the aforementioned enhanced attribute graph only randomly perturbs the topology and does not incorporate node attribute information for targeted optimization and filtering of the graph structure. (1) Randomly adding or deleting edges lacks attribute guidance. It cannot remove noisy edges that are topologically adjacent but have greatly different semantic attributes, nor can it complete potential node associations that are highly similar in attributes but not topologically related. As a result, the attribute-topology mismatch noise in the original graph will be directly retained in the augmented view and passed to the subsequent encoding process, continuously interfering with the accuracy of node representation. (2) The semantic consistency of the augmented view is difficult to guarantee. Random attribute occlusion alone lacks Laplace topological smoothing constraints. The perturbation of node attributes is completely decoupled from the topological structure. The generated augmented view is prone to excessive semantic shift, which introduces additional distribution noise. This causes the node representation learned by the encoder to be mixed with too much invalid information, ultimately leading to a decrease in the accuracy of the clustering results.

[0009] Moreover, the above-mentioned method of using a single encoder with shared full parameters to encode all views cannot simultaneously achieve the dual learning objectives of fine-grained feature differentiation of nodes and cluster-level structural feature aggregation. (1) The encoding method with shared full parameters forces all nodes to follow a unified feature mapping rule, which is difficult to adapt to the attribute distribution and local topological differences of different nodes. It is easy to over-smooth the feature differences of individual nodes, resulting in a decrease in the fine-grained differentiation ability of node representations and an inability to support accurate clustering. (2) Since there is no encoding branch with shared cluster-level parameters, the model cannot establish consistent feature mapping constraints at the clustering semantic level. It can only construct contrastive losses in two dimensions: individual nodes and global aggregation. It is difficult to capture high-order community structure features and cannot guide the encoder to learn cluster-level representations that meet the clustering objectives. In the end, the intra-cluster consistency and modularity of the clustering results are difficult to achieve ideal results. In addition, the method of directly integrating the maximum modularity loss into the comprehensive loss in the form of continuous relaxation for end-to-end optimization: (1) It is easy to get trapped in local optima and it is difficult to obtain the global optimal clustering structure. The continuous relaxation of modularity calculation weakens the discrete combination characteristics of community partitioning, loses the global search capability of discrete community structure, and the optimization process is prone to converge to local optimum solution, and cannot obtain the globally optimal community clustering partition. (2) The optimization objectives are prone to conflict and the training stability is poor. There is a natural tension between the modularity optimization objective and the contrastive learning optimization objective. The former pursues the high aggregation of features within the cluster, while the latter pursues the discriminativeness of features between nodes. The continuous relaxation direct coupling method cannot balance the optimization rhythm and weight of the two, and is prone to loss oscillation and clustering effect imbalance during training. It is impossible to achieve high-quality node representation learning and community structure mining at the same time. Summary of the Invention

[0010] The purpose of this invention is to provide an attribute graph clustering method, apparatus, and medium based on contrastive learning, in order to solve the technical problem that existing graph clustering methods based on contrastive learning are susceptible to noise interference from attribute-topology inconsistencies, resulting in a serious decline in clustering quality.

[0011] To address the aforementioned technical problems, the first aspect of this invention provides an attribute graph clustering method based on contrastive learning, the method comprising:

[0012] S1. Obtain the node attribute matrix representing all node attributes and the original adjacency matrix representing the connection relationships between nodes from the attribute graph to be clustered.

[0013] S2. For each node, take the K nearest nodes in the attribute space as the attribute neighbors of the node, and construct an attribute adjacency matrix based on the attribute neighbors of each node; then, merge the attribute adjacency matrix and the original adjacency matrix to obtain the enhanced adjacency matrix.

[0014] S3. Construct a Laplace filter based on the enhanced adjacency matrix, and filter the node attribute matrix using the Laplace filter to obtain a smoothed node attribute matrix.

[0015] S4. Cluster based on the node smoothing attribute matrix.

[0016] In one possible implementation, the attribute adjacency matrix and the original adjacency matrix are merged by weighted addition.

[0017] In one possible implementation, the attribute adjacency matrix used for merging with the original adjacency matrix is ​​a symmetrically modified attribute adjacency matrix.

[0018] In one possible implementation, the symmetry processing is performed as follows:

[0019]

[0020] in, and These are the attribute adjacency matrices before and after symmetry processing, respectively.

[0021] In one possible implementation, the process of clustering based on the node smoothing attribute matrix includes: inputting the node smoothing attribute matrix into pre-trained different first encoders and second encoders to obtain embedding representations under two different views; fusing the two embedding representations to obtain a consensus embedding representation; and performing clustering based on the consensus embedding representation.

[0022] In one possible implementation, the total loss function used to train the first and second encoders includes a node-level neighborhood contrastive loss as shown below. :

[0023]

[0024]

[0025]

[0026] in, For matrix The Line number Column elements, and These are the embedded representations output by the first encoder and the second encoder, respectively; For matrix The Line number Column elements, To enhance the adjacency matrix, It is an identity matrix.

[0027] In one possible implementation, the total loss function further includes cluster-level contrastive loss based on InfoNCE. .

[0028] In one possible implementation, the total loss function also includes a macroscopic modularity maximization loss. :

[0029]

[0030]

[0031]

[0032] in, and Represent matrices respectively and The Line number Column elements, matrix This is the original adjacency matrix. Indicates the first The degree of each node. Representation of attribute graph The number of edges in and These represent the third encoder and its learnable parameters, respectively. For consensus embedding representation, This represents the softmax function. This indicates the computation of the trace of a matrix.

[0033] In one possible implementation, S4 uses the K-means algorithm for clustering.

[0034] To address the aforementioned technical problems, a second aspect of the present invention provides an attribute graph clustering apparatus based on contrastive learning, comprising a processor for executing a computer program to implement the steps of the method in any possible implementation of the first aspect of the present invention.

[0035] To address the aforementioned technical problems, a third aspect of the present invention provides a computer-readable storage medium storing a computer program internally, the computer program being executed by a processor to implement the steps of the method in any possible implementation of the first aspect of the present invention.

[0036] The beneficial effects of this invention are as follows: This invention significantly suppresses noise caused by attribute-topology inconsistency and improves clustering quality through four key steps. First, for each node, K nearest neighbors are selected in the attribute space to construct an attribute adjacency matrix, ensuring that nodes with similar attributes are necessarily connected. This matrix is ​​then weighted and fused with the original adjacency matrix, which can correct attribute isolation or structural noise while preserving the true topology, achieving synergistic enhancement of attribute and structure. Next, a symmetric normalized Laplace filter is generated based on the fused enhanced adjacency matrix, and multi-layer low-pass filtering is applied to the attribute matrix to complete the smooth propagation of attributes. This process unifies the features of adjacent nodes with similar attributes, weakens the disturbance of abnormal attribute points, and naturally suppresses noise. Finally, clustering is performed directly in the smoothed attribute space, resulting in features with high homogeneity and low noise, making cluster centers easier to distinguish. This invention solves the technical problem that existing graph clustering methods based on contrastive learning are easily affected by noise interference from attribute-topology inconsistency, leading to a severe decline in clustering quality. Attached Figure Description

[0037] Figure 1 This is a diagram showing the overall architecture of the NC-MGC framework in the implementation of the attribute graph clustering method based on contrastive learning of this invention.

[0038] Figure 2 This is a flowchart of graph optimization in the implementation of the attribute graph clustering method based on contrastive learning of the present invention;

[0039] Figure 3 This is a schematic diagram of node-level contrastive learning in the implementation of the attribute graph clustering method based on contrastive learning of the present invention;

[0040] Figure 4 This is a schematic diagram of cluster-level contrastive learning in the implementation of the attribute graph clustering method based on contrastive learning of the present invention;

[0041] Figure 5 This is a schematic diagram illustrating the maximization of modularity in the implementation of the attribute graph clustering method based on contrastive learning of the present invention;

[0042] Figure 6 This is an overall flowchart of the implementation of the attribute graph clustering method based on contrastive learning of the present invention. Detailed Implementation

[0043] This invention significantly suppresses noise caused by attribute-topology inconsistencies and improves clustering quality through four key steps. First, for each node, K nearest neighbors are selected in the attribute space to construct an attribute adjacency matrix, ensuring that nodes with similar attributes are always connected. This matrix is ​​then weighted and fused with the original adjacency matrix, correcting attribute isolation or structural noise while preserving the true topology, achieving synergistic enhancement of attribute and structure. Next, a symmetric normalized Laplace filter is generated based on the fused enhanced adjacency matrix, applying multi-layer low-pass filtering to the attribute matrix to achieve smooth attribute propagation. This process unifies the features of adjacent nodes with similar attributes, weakening the disturbance of abnormal attribute points and naturally suppressing noise. Finally, clustering is performed directly in the smoothed attribute space, resulting in features with high homogeneity and low noise, making cluster centers easier to distinguish. This invention solves the technical problem of existing graph clustering methods based on contrastive learning being susceptible to noise interference from attribute-topology inconsistencies, leading to a severe decline in clustering quality.

[0044] To make the objectives, technical solutions, and advantages of the present invention clearer, the technical solutions of the present invention will be further described in detail below with reference to the accompanying drawings.

[0045] Implementation of Attribute Graph Clustering Method Based on Contrastive Learning:

[0046] The existing property graph clustering technology has the following problems:

[0047] (1) Attribute-topology inconsistency and high-frequency noise in the original attribute graph. Nodes with similar attributes in real graph data are not necessarily directly connected, existing edges may represent cross-domain associations, and node features contain high-frequency noise. Directly relying on the original data causes graph convolutional networks to aggregate irrelevant information, leading to representation collapse and a serious decline in clustering quality.

[0048] (2) Topological sparsity and structural incompleteness. Real graphs such as citation networks and social networks often have missing edges. Nodes with similar attributes but no topological connection cannot interact effectively through graph convolution, which limits the representation learning ability.

[0049] (3) The fragmentation problem of representation caused by single-granularity contrastive learning. Node-level contrastive learning lacks meso-cluster semantic guidance. Although the learned embeddings are locally consistent, they are globally fragmented, the cluster boundaries are blurred, and the inter-class separability is insufficient.

[0050] (4) The disconnect between the optimization objective and the community structure. The optimization objective of the contrastive learning does not explicitly consider the community organization principle of the graph, and the learned partitions lack macro-topological cohesion, which cannot meet the needs of community discovery in practical applications.

[0051] Based on the aforementioned technical problems, the basic technical concept of this invention is as follows: Addressing the issues of attribute-topology inconsistency and high-frequency noise, this invention employs a node attribute-based K-Nearest Neighbors (KNN) algorithm to reconstruct the original adjacency matrix representing topological connections into an attribute adjacency matrix representing node similarity. The attribute adjacency matrix and the original adjacency matrix are then fused to obtain an enhanced adjacency matrix. Finally, a residual Laplace filter layer with stacked r layers is used for smoothing. KNN reconstruction deterministically completes topological sparsity from the attribute side, and Laplacian filtering (equivalent to low-pass filtering) suppresses high-frequency noise, achieving a synergistic effect of attribute-driven adaptive graph topology reconstruction and noise suppression. For the fragmentation of representations caused by single-granularity contrastive learning and the technical problem of the optimization objective of contrastive learning being disconnected from the community structure, this invention introduces a three-granularity collaborative optimization that integrates node-level and cluster-level dual-track contrastive learning to maximize modularity. At the node level, complementary view embeddings are generated through dual encoders, and local consistency is achieved through a neighborhood contrastive loss based on MSE. At the cluster level, a cluster assignment matrix is ​​generated using a parameter-shared twin encoder, and cluster prototype separation is optimized through InfoNCE loss. Newman modularity is introduced as a global optimization objective, and continuous relaxation is transformed into a differentiable loss function, which is then used in conjunction with contrastive loss for end-to-end training. This achieves a three-granularity collaborative optimization of local consistency, meso-level cluster semantics, and macro-level community structure.

[0052] The attribute graph described in this embodiment can be widely applied to various graph data scenarios that include node relationships and node feature information, and can support a variety of downstream tasks such as community discovery, group segmentation, functional clustering, and risk identification. For example:

[0053] 1. Social Network Domain: Node Meaning: A user account or user entity on a social platform. Node Attribute Meaning: Covers two categories: static attributes and behavioral attributes. Static attributes include basic characteristics such as user location, age, gender, and account registration information; behavioral attributes include dynamic characteristics such as user interest tags, semantic features of published content, content posting frequency, interaction preferences, and consumption tendencies. Edge Meaning: Represents the relationship between nodes, including bidirectional friend relationships and group relationships, as well as one-way follow relationships and interactive relationships (likes, comments, reposts, @mentions, etc.). In this scenario, there is a common attribute-topology inconsistency problem where users with highly similar interests do not establish direct friend relationships, and cross-circle interactions form noisy edges, which is highly compatible with the optimization objective of this method.

[0054] 2. Academic Citation Network Domain: Node Meaning: Single academic document, research author, or research institution. Node Attribute Meaning: Taking a document node as an example, attributes include the document's subject keywords, semantic features of the abstract and title, research field classification, journal and publication date, author team, and funding information; for an author node, attributes include the author's research direction, number of publications, affiliated institution, and academic influence indicators.

[0055] The meaning of edges: They represent citation and co-citation relationships between documents, or collaborative publication relationships between authors, or project collaboration relationships between institutions. In this scenario, many documents with similar research topics do not have direct citation relationships, and there is also weak association noise formed by cross-domain citations. This is a typical application scenario with topological sparsity and attribute-topological inconsistency problems.

[0056] 3. E-commerce User and Product Network Domain: Node Meaning: Divided into two categories: user nodes and product nodes. Node Attribute Meaning: User node attributes include user membership level, spending power, category preferences, browsing behavior characteristics, region, and active time period, etc.; product node attributes include product category, brand, price range, sales volume, semantic features of product description, and target audience tags, etc.

[0057] The meaning of edges: Edges between user nodes represent shared browsing, shared favorites, and shared purchase behaviors; edges between product nodes represent bundled purchases, substitution within the same category, and association with the same user group; edges between users and products represent interactive relationships such as browsing, favorites, adding to cart, and purchasing. This scenario can achieve user segmentation and product stratification through attribute graph clustering, serving precise recommendation and user operation scenarios.

[0058] 4. Biological Protein Interaction Networks: Node Meaning: Various protein molecules or gene fragments. Node Attribute Meaning: Includes biological characteristics such as protein amino acid sequence features, domain types, functional annotation information, tissue expression abundance, and subcellular localization. Edge Meaning: Represents physical interactions, functional synergistic regulatory relationships, and signaling pathway associations between proteins. In this scenario, limited by experimental detection conditions, many functionally similar proteins have not yet been found to have interaction relationships, resulting in insufficient topological integrity. This method can improve the accuracy of protein functional clustering through attribute-driven topology optimization.

[0059] 5. Financial Risk Control Network Domain: Node Meaning: Financial accounts, corporate entities, individual entities, or transaction terminals. Node Attribute Meaning: Includes characteristics such as account transaction frequency, fund flow scale, transaction time period characteristics, industry, registration information, credit rating, and historical risk tags. Edge Meaning: Represents fund transfer relationships, equity connections, guarantee relationships, common counterparty connections, device login connections, etc., between accounts. This scenario can identify abnormal groups and associated risk entities through attribute graph clustering. Fraudulent groups often conceal direct connections through multi-layered fund transfers, exhibiting a typical attribute-topology inconsistency problem where attributes are similar but the topology has no direct connection.

[0060] This implementation proposes an attribute graph clustering method based on node-cluster contrastive learning and modularity maximization (NC-MGC method for short), such as... Figure 6 As shown, this method first applies attribute-enhanced adjacency reconstruction and Laplace joint filtering to the original node attribute matrix. Graph optimization is performed to obtain an optimized node attribute matrix that includes attribute information and topological information but with enhanced attributes. Then, based on the trained graph encoder... Generate consensus embedding Consensus-based embedding The final clustering is completed using the K-means or Louvain algorithm.

[0061] Specifically, such as Figure 1 As shown, the NC-MGC method of this embodiment includes the following steps:

[0062] Step 1: Graph Optimization – Attribute Augmentation, Adjacency Reconstruction, and Laplace Joint Filtering.

[0063] To address the attribute-topology inconsistency problem, this implementation proposes a four-step graph optimization strategy: KNN attribute reconstruction → symmetry → weighted fusion → Laplace filtering. KNN reconstruction deterministically completes the topological sparsity from the attribute side, bridging nodes with similar attributes but no topological connections; symmetry preserves bidirectional and unidirectional neighbor relationships; weighted fusion achieves the organic integration of attribute and topological information; stacking r layers is equivalent to residual Laplace filtering with low-pass spectrum filtering, suppressing high-frequency noise.

[0064] For a given attribute graph , This represents the node attribute matrix, which consists of the attributes of all nodes. For the number of nodes, For attribute dimensions; It is an adjacency matrix, and it is used through the adjacency matrix. Representation of attribute graph The connection relationships between nodes, adjacency matrix The Line number Column elements The value can be 0 or 1. Indicates the first The and the first If a node has a connection relationship, then it does not; otherwise, it does not.

[0065] The above uses an adjacency matrix To describe the attribute graph The topology is such that, however, in real graph data, nodes with similar attributes are not necessarily directly connected, and existing edges may represent cross-domain relationships. This inconsistency between attributes and topology makes it easy to aggregate irrelevant information during clustering, affecting clustering quality. Therefore, this implementation enhances the adjacency matrix based on node attributes. Specifically, as follows... Figure 2 As shown, it includes the following steps:

[0066] Step 1.1: Based on the node attribute matrix The attribute adjacency matrix is ​​reconstructed using the K-Nearest Neighbors (KNN) algorithm.

[0067] For property graphs For each node, calculate the distance between that node and the other nodes in the attribute space. Generally, the closer the distance between two nodes in the attribute space, the more similar the two nodes are. Therefore, in this implementation, select the K closest nodes to the current node as its attribute neighbors and construct an attribute adjacency matrix. .

[0068] Attribute Adjacency Matrix The The line represents the first The attribute neighbors of each node, i.e. The Line number Column elements Indicates the first The distance to the node is... One of the K nearest nodes to a given node, and vice versa. .

[0069] In this embodiment, for the sake of simplicity, the above distance is the Euclidean distance. Nodes and the Nodes Euclidean distance between for:

[0070]

[0071] in, Represents a node The Each attribute.

[0072] In other implementations, the above distance can also be replaced by other distance metrics that can represent similar distances as needed, such as Manhattan distance in scenarios where more robustness to outliers is required, or cosine distance in scenarios where more focus is on direction than scale.

[0073] Step 1.2: Obviously, the above attribute adjacency matrix... It is asymmetric, therefore, for the attribute adjacency matrix The symmetry is adjusted as shown in the following equation:

[0074]

[0075] in, express The transpose of .

[0076] Step 1.3: The attribute adjacency matrix after symmetry processing... With the original adjacency matrix Weighted fusion yields the enhanced adjacency matrix:

[0077]

[0078] in, Here, is the balance coefficient, and is the hyperparameter. Enhanced adjacency matrix. While preserving the true topology, it corrects attribute isolation or structural noise, achieving synergistic enhancement of attributes and structure.

[0079] Step 1.4, Add a self-loop:

[0080]

[0081] in, It is an identity matrix.

[0082] calculate degree matrix :

[0083]

[0084] in, This represents a diagonal matrix.

[0085] Step 1.5: Calculate the symmetric normalized Laplace filter:

[0086]

[0087] Step 1.6: Stack r-layer residual Laplace filter layers, node attribute matrix After r-layer residual Laplace filter processing, high-frequency noise is filtered out:

[0088]

[0089] This is the filtered node attribute matrix, i.e., the node smoothing attribute matrix.

[0090] Step 2, Node-level comparative learning – local consistency alignment of dual views without parameter sharing.

[0091] To address the fragmentation problem of single-granularity characterization, this invention proposes a dual-track encoder design: node-level parameters are not shared. The dual MLP encoder extracts complementary view information, and the cluster level uses parameter sharing (the same...) The twin encoder forces views to align in a unified latent space. Node-level alignment is based on an enhanced adjacency matrix. Define positive and negative sample pairs directly and use MSE loss. Alignment achieves local consistency without requiring random data augmentation. For example... Figure 3 As shown, it includes the following steps:

[0092] Step 2.1, Input two MLP encoders with identical structures but different parameters to obtain... Embedded representation in two different views and :

[0093]

[0094]

[0095] in, and These represent the first encoder and its learnable parameters, respectively. and These represent the second encoder and its learnable parameters, respectively.

[0096] In this scheme, the dual encoders adopt a design with consistent structure and independent parameters. This is determined by the core mechanism of contrastive learning and the attribute graph representation target of this invention. The core reasons are as follows:

[0097] 1. Ensuring Feature Space Consistency in Contrastive Learning: The core logic of contrastive learning is to learn robust node representations within the same feature space by bringing positive sample pairs closer together and pushing negative sample pairs further apart. Identical encoder structures ensure that the output embedding vectors reside in the same dimensional and distributed semantic feature space. In this case, the calculated contrastive loss has a clear physical meaning and can effectively guide the model to learn the essential semantic features of nodes, rather than distributional differences caused by architectural variations. If the feature spaces are inconsistent, the similarity calculation between nodes will lack a benchmark, and the contrastive loss will fail to perform its optimization function.

[0098] 2. Ensuring fairness and gradient stability in dual-branch training: Two encoders with identical structures possess completely consistent representational capabilities and parameter magnitudes, learning feature mappings under different augmented views only through independent parameters. This design ensures symmetrical optimization rhythms and balanced gradient backpropagation amplitudes between the two branches. It avoids the leakage of view information caused by parameter sharing in a single encoder and prevents one branch from dominating the loss while the other is undertrained due to differences in model capacity, thus guaranteeing stable convergence during training.

[0099] 3. Adapting to the clustering objective of dual-view comparison in this invention: In this embodiment, the two encoders correspond to the feature extraction of two enhanced attribute views, respectively. The identical structure eliminates interference from the model architecture itself, allowing parameter differences to focus solely on capturing node feature patterns under different views. Ultimately, the representations output by the two branches possess both feature complementarity and reside in a unified feature space, enabling direct use for subsequent similarity calculations and clustering, ensuring the accuracy and stability of the clustering results.

[0100] Using two encoders with completely different structures would fundamentally undermine the optimization basis of contrastive learning, leading to multiple technical defects and failing to achieve the intended effect of this invention, as follows:

[0101] 1. Heterogeneous feature spaces cause contrastive targets to fail: Structural differences (such as different numbers of layers, different hidden dimensions, different activation functions, etc.) will cause fundamental differences in the feature distribution and semantic space of the outputs of two encoders. During model optimization, an "architectural shortcut" may appear—that is, the model can reduce the contrastive loss simply by distinguishing the output features of different encoders, without learning the semantic features of the nodes themselves. This completely deviates from the original intention of contrastive learning, and the final node representation does not have effective clustering discriminative power.

[0102] 2. Training imbalance leads to uncontrollable representation quality: Encoders with different structures have varying parameter counts and fitting capabilities. During training, an imbalance can easily occur, where "strong encoders" converge quickly or even overfit, while "weak encoders" consistently underfit, causing the loss function to oscillate continuously and fail to converge stably. Simultaneously, differences in gradient backpropagation amplitude lead to asynchronous parameter updates, further exacerbating the shift in representation distribution and preventing the output of high-quality node embeddings.

[0103] 3. Poor feature compatibility in downstream clustering tasks: The ultimate goal of this invention is to achieve attribute graph clustering, which requires calculating similarity based on node embedding and completing cluster partitioning. The feature semantic spaces output by encoders with different structures are not uniform. Whether directly concatenated or used alone for clustering, inconsistent feature measurement benchmarks will lead to decreased intra-cluster consistency and blurred inter-cluster boundaries, ultimately severely impairing the clustering effect.

[0104] Step 2.2: Embedding the dual views and Proceed by row Normalization is used to ensure comparability of cross-view embeddings.

[0105]

[0106]

[0107] Step 2.3: Based on the normalized... and Calculate the cross-view similarity matrix:

[0108]

[0109] Step 2.4: Define the neighborhood contrast loss based on MSE. :

[0110]

[0111] in, For matrix The Line number The elements of the column represent The first view under Each node and The first view under The degree of cross-view similarity between nodes. For connected nodes, the push For unconnected nodes to drive N is the number of nodes.

[0112] In other implementations, only graph optimization and node-level comparison are used. Removing cluster-level comparison and modularity maximization simplifies the total loss to... This simplified version still outperforms existing node-level-only comparison methods (due to graph optimization), but its performance is lower than the full version. It is suitable for scenarios with limited computational resources.

[0113] Step 3: Cluster-level comparative learning – meso-level semantic separation of parameter-shared twin encoders.

[0114] To achieve meso-level semantic alignment and separation on the attribute-topology graph, this invention introduces a cluster-level contrastive learning module after node-level contrastive learning. This module generates a soft clustering assignment matrix through a parameter-shared Siamese encoder, thereby obtaining the cluster centroids, and uses a contrastive loss of the form InfoNCE. Strengthen semantic consistency of the same cluster across different views and separate cross-cluster semantics. For example... Figure 4 As shown, the specific steps include:

[0115] Step 3.1: Dual-view embedded input parameter sharing twin encoder :

[0116]

[0117]

[0118] and These represent the third encoder and its learnable parameters, respectively. and This represents the soft allocation matrix under two views.

[0119] Step 3.2: Calculate the normalized result. and Consensus Embedding :

[0120]

[0121] Step 3.3: Calculate the centroid of the two-view cluster. and :

[0122]

[0123]

[0124] Step 3.4: Define the cluster-level contrast loss based on InfoNCE. The centroid pairs of the same cluster in both views are taken as positive samples, and all cross-cluster centroid pairs are taken as negative samples. The symmetric design is used to calculate the average after bidirectional calculation.

[0125] The InfoNCE loss for a positive centroid pair relative to a negative sample is:

[0126]

[0127] in, Indicates the first The centroid pairs of the cluster are positive samples. InfoNCE loss under view; For temperature parameters; This indicates calculating the similarity between two vectors. The number of clusters; and They are respectively and The Column, representing the first The centroid of the cluster in the corresponding view.

[0128] Correspondingly, the comparative loss is calculated by averaging after bidirectional calculation. for:

[0129]

[0130] in, Indicates the first The centroid pairs of the cluster are positive samples. InfoNCE loss under view.

[0131] In other implementations, InfoNCE loss can be used instead of MSE loss for node-level comparison. The definitions of positive and negative samples remain unchanged (i.e., the construction logic of positive and negative samples is consistent with that of cluster-level comparison loss), but the loss function is changed to a comparison form. This approach can slightly improve performance, but increases the tuning cost of the temperature parameter τ.

[0132] "The definition of positive and negative samples remains unchanged" means that when the node-level contrastive loss adopts the InfoNCE form instead of the original MSE form, the construction logic of positive and negative samples remains consistent with that of the cluster-level contrastive loss, both following the core rule that "samples across views within the same index are positive samples, and samples from different indexes (including the entire cross-view set and other samples within the same view) are negative samples." The only difference lies in the granularity of the optimized unit: at the node level, a single node embedding is used as the unit, and positive samples are cross-view embedding pairs of the same node; at the cluster level, the cluster centroid is used as the unit, and positive samples are cross-view centroid pairs of the same cluster index. The construction rules for positive and negative samples remain unchanged when the loss function is changed at the node level.

[0133] Compared with cluster-level InfoNCE loss, node-level InfoNCE loss has the following characteristics: (1) Different optimization granularity and objects: node-level contrastive loss uses the embedding vector of a single node as the optimization unit, which belongs to fine-grained representation constraints and aims to improve the robustness and discriminativeness of individual node representations; cluster-level contrastive loss uses the overall centroid vector of the cluster as the optimization unit, which belongs to coarse-grained clustering structure constraints and aims to align cluster-level semantics under dual views and strengthen the cross-view nature of the clustering structure. Figure 1 Consistency and inter-cluster discriminability. (2) The composition and computational scale of negative samples are different: the computational scale of node-level contrastive loss corresponds to the total number of nodes N, and the negative sample size is N; the computational scale of cluster-level contrastive loss corresponds to the total number of clusters C, and the negative samples simultaneously include all clusters across views and other clusters within the same view, with computational complexity far lower than that of node-level. (3) The technical roles and effects are different: node-level contrastive loss mainly opposes the node representation shift caused by view perturbation, which is the basis for generating high-quality node representations and serves general graph representation learning; cluster-level contrastive loss directly serves the clustering task, guides the model to learn cluster-level features that conform to the clustering goal, widens the inter-cluster representation distance, and improves the intra-cluster consistency and inter-cluster separation of the final clustering results.

[0134] Step 4: Maximize modularity – Macro-level community structure constraints.

[0135] To address the disconnect between the comparative optimization objective and the community structure, this invention incorporates Newman modularity... Transformed into a differentiable loss through continuous relaxation End-to-end training is performed in conjunction with contrastive loss. Soft-assigned matrix. It is a continuous relaxation of discrete community allocation, which allows the modularity to be adjusted. Find the gradient. For example... Figure 5 As shown, it includes the following steps:

[0136] Step 4.1: Based on the original adjacency matrix Pre-compute modularity matrix :

[0137]

[0138] in, and Represent matrices respectively and The Line number Column elements; Representation based on the original adjacency matrix The The degree of each node; Representation of attribute graph The number of edges in the array.

[0139] Step 4.2: Embedding based on consensus via the third encoder The soft allocation matrix is ​​obtained from this:

[0140]

[0141] in, It is a soft-assignment matrix; This represents the softmax function.

[0142] Step 4.3: Calculate Newman modularity :

[0143]

[0144] in, This indicates the computation of the trace of a matrix.

[0145] Step 4.5, Define the loss for maximizing modularity as:

[0146]

[0147] Step 5: Construct the joint loss and perform end-to-end optimization.

[0148] Step 5.1: Construct the total loss function, i.e., the joint loss:

[0149]

[0150] and is a weighting coefficient used to adjust the contribution of different losses to the final loss.

[0151] Step 5.2: Minimize the total loss end-to-end using the Adam optimizer and update all learnable parameters. .

[0152] Step 6: Final clustering.

[0153] Step 6.1: After training, calculate the final consensus embedding. .

[0154] Step 6.2, embedding consensus Perform K-means clustering to obtain the cluster label for each node. C represents the number of clusters.

[0155] In other implementations, the Louvain algorithm is used instead of K-means for the final clustering. Modular optimization is performed directly on the enhanced adjacency matrix without pre-setting the number of clusters C, but the clustering results may not be entirely consistent with the objective of contrastive learning optimization.

[0156] Implementation of an attribute graph clustering device based on contrastive learning:

[0157] The attribute graph clustering device based on contrastive learning in this embodiment specifically includes a memory, a processor, a system bus, and a computer program stored in the memory. The processor and the memory communicate and interact with each other via the system bus. The processor executes the computer program to implement the steps of the attribute graph clustering method based on contrastive learning described in this embodiment of the present invention. The specific attribute graph clustering method based on contrastive learning has been described in sufficient detail in the above-described embodiment and will not be repeated here. The processor can be a microprocessor (MCU) or other processing device; the memory can be any type of memory that stores information using electrical energy, such as non-volatile storage media (including computer programs, databases), or other types of memory.

[0158] The attribute graph clustering device based on contrastive learning in this embodiment can be widely deployed in industry scenarios that require clustering using both node attributes and topological structure:

[0159] 1. Enterprise Knowledge Graph and Business Network: Within enterprises in industries such as finance, manufacturing, and pharmaceuticals, business entities (e.g., customers, suppliers, patents, products) are often accompanied by attributes (industry, region, technology tags) and complex relationship networks. The device effectively suppresses noise caused by attribute-topology inconsistencies through attribute neighbor reconstruction, enhanced adjacency fusion, and Laplace smoothing, helping enterprises quickly segment business ecosystems and discover potential partners or risk clusters. Deployment is typically as a backend service (Docker / Kubernetes containers) or an internal enterprise big data platform (Spark / Flink). Inputs are existing attribute and relationship tables, and outputs clustering labels for the decision engine to use.

[0160] 2. Academic / Research Graph Analysis: In graphs of papers, patents, and research projects, the metadata (authors, keywords, affiliated institutions) of nodes often does not match their citation / collaboration relationships. The device can be deployed as a microservice within academic search platforms or research management systems to receive new literature or patent data in real time, perform attribute-structure unified clustering, and thus achieve topic aggregation, prediction of disciplinary evolution trends, or expert recommendations.

[0161] 3. Social Media and Recommendation Systems: The personal characteristics (interests, consumption tags) and social connections of social network users are often subject to noise. The device can be embedded into large model inference platforms (such as TensorFlow Serving and ONNX Runtime) to generate community segments using offline batch processing, and then provide community tags in the online recommendation process to improve the recall accuracy of similar users and the diversity of content distribution.

[0162] The core modules of the device (attribute adjacency generation, Laplace filtering, and contrastive learning) all implement GPU-accelerated matrix operations, and can meet the processing needs of graph data ranging from thousands to millions of people through containerized deployment and auto-scaling (Kubernetes HPA).

[0163] Implementation of computer-readable storage media:

[0164] A computer-readable storage medium stores a computer program internally, the computer program being executed by a processor to implement the steps of the contrastive learning-based attribute graph clustering method described above. The specific contrastive learning-based attribute graph clustering method has been described in sufficient detail in the above-described implementations and will not be repeated here.

[0165] The attribute graph clustering method in this embodiment is stored in the form of program code on any readable computer-readable medium, including but not limited to disk storage media (hard disk, USB flash drive, etc.), network storage media (server hard disk array, cloud storage object), and programmable memory (Flash, EEPROM, SD card, etc.).

[0166] The program code includes modular software units for implementation: ① attribute neighbor construction unit; ② adjacency fusion unit; ③ Laplace filter unit; ④ contrastive learning unit and clustering unit. This code can be implemented using programming languages ​​such as Python, C++, and Java, and packaged together with supporting libraries (such as PyTorch, TensorFlow, and NumPy) into an executable file or script, stored on any of the aforementioned computer-readable media.

[0167] When the medium is loaded onto a general-purpose computer, server, or embedded processor, the control unit (CPU / GPU) reads and executes the program code in the medium, sequentially completing the acquisition of the node attribute matrix, the original adjacency matrix, the reconstruction and fusion of attribute adjacency, Laplace filtering, and the clustering task based on contrastive learning, and finally outputting the clustering labels.

[0168] The computer-readable storage medium can be the memory in the aforementioned attribute graph clustering device based on contrastive learning, directly used as a step for implementing the aforementioned attribute graph clustering method based on contrastive learning; or it can simply be used as a storage medium for the aforementioned computer program, such as a hard disk, which can transfer the computer program to another storage medium to implement the aforementioned attribute graph clustering method based on contrastive learning.

[0169] This invention has the following characteristics:

[0170] (1) Three-level granularity collaborative optimization to comprehensively improve clustering quality. This invention simultaneously and explicitly optimizes three granularity levels within the same framework: local consistency (graph optimization + node-level comparison), meso-level cluster semantics (cluster-level comparison), and macro-level community structure (maximizing modularity). Each module enhances the others rather than being simply spliced ​​together.

[0171] (2) Attribute-driven adaptive graph reconstruction effectively solves the attribute-topology inconsistency problem. Through a four-step graph optimization strategy of KNN attribute reconstruction + symmetry + weighted fusion + Laplace filtering, the topology is deterministically reconstructed from the attribute side to make up for the topological sparsity and suppress high-frequency noise.

[0172] (3) Dual-track encoder architecture, which takes into account both view complementarity and spatial alignment. At the node level, the dual encoders do not share parameters to capture complementary view information, while at the cluster level, the twin encoders share parameters to force the views to align in a unified latent space.

[0173] (4) The modularity theory is deeply integrated into contrastive learning to achieve explicit differentiable optimization. The Newman modularity is transformed into a differentiable loss function through continuous relaxation, and it is trained end-to-end in conjunction with the contrastive loss, which is different from existing methods that only implicitly optimize the modularity or use discrete combinatorial optimization.

[0174] (5) Neighborhood comparison replaces random augmentation, eliminating the need for data augmentation and being computationally efficient. Positive and negative sample pairs are directly defined based on the augmented adjacency matrix, avoiding the uncertainty of random perturbations and additional computational overhead.

[0175] (6) No cluster center initialization is required, avoiding initialization pitfalls. Based on the contrastive learning paradigm, it does not rely on precise initialization of cluster centers and cumbersome pre-training, resulting in higher computational efficiency and stronger robustness.

[0176] (7) End-to-end training, simple to implement. All modules are micronable, can be implemented based on mainstream deep learning frameworks, and support GPU acceleration.

[0177] Finally, it should be noted that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still make modifications to the technical solutions described in the foregoing embodiments without creative effort, or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. An attribute graph clustering method based on contrastive learning, characterized in that, The method includes: S1. Obtain the node attribute matrix representing all node attributes and the original adjacency matrix representing the connection relationships between nodes from the attribute graph to be clustered. S2. For each node, take the K nearest nodes in the attribute space as the attribute neighbors of the node, and construct an attribute adjacency matrix based on the attribute neighbors of each node; then, merge the attribute adjacency matrix and the original adjacency matrix to obtain the enhanced adjacency matrix. S3. Construct a Laplace filter based on the enhanced adjacency matrix, and filter the node attribute matrix using the Laplace filter to obtain a smoothed node attribute matrix. S4. Cluster based on the node smoothing attribute matrix.

2. The attribute graph clustering method based on contrastive learning according to claim 1, characterized in that, The method for merging the attribute adjacency matrix and the original adjacency matrix is ​​a weighted sum.

3. The attribute graph clustering method based on contrastive learning according to claim 1 or 2, characterized in that, The attribute adjacency matrix used for merging with the original adjacency matrix is ​​the attribute adjacency matrix after symmetry processing.

4. The attribute graph clustering method based on contrastive learning according to claim 3, characterized in that, The method of symmetry processing is as follows: in, and These are the attribute adjacency matrices before and after symmetry processing, respectively.

5. The attribute graph clustering method based on contrastive learning according to claim 1, characterized in that, The process of clustering based on the node smoothing attribute matrix includes: inputting the node smoothing attribute matrix into pre-trained first encoders and second encoders to obtain two different embedding representations under different views; fusing these two embedding representations to obtain a consensus embedding representation; and performing clustering based on the consensus embedding representation.

6. The attribute graph clustering method based on contrastive learning according to claim 5, characterized in that, The total loss function used to train the first and second encoders includes the node-level neighborhood contrast loss as shown below. : in, For matrix The Line number Column elements, and These are the embedded representations output by the first encoder and the second encoder, respectively; For matrix The Line number Column elements, To enhance the adjacency matrix, It is an identity matrix.

7. The attribute graph clustering method based on contrastive learning according to claim 6, characterized in that, The total loss function also includes cluster-level contrastive loss based on InfoNCE. .

8. The attribute graph clustering method based on contrastive learning according to claim 6 or 7, characterized in that, The total loss function also includes macro-modularity maximization loss. : in, and Represent matrices respectively and The Line number Column elements, matrix This is the original adjacency matrix. Indicates the first The degree of each node. Representation of attribute graph The number of edges in and These represent the third encoder and its learnable parameters, respectively. For consensus embedding representation, This represents the softmax function. This indicates the computation of the trace of a matrix.

9. An attribute graph clustering device based on contrastive learning, comprising a processor, characterized in that, The processor is used to execute a computer program to implement the steps of the attribute graph clustering method based on contrastive learning as described in any one of claims 1 to 8.

10. A computer-readable storage medium, wherein a computer program is stored internally, characterized in that, The computer program is executed by a processor to implement the steps of the attribute graph clustering method based on contrastive learning as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Multi-view clustering model implementation method based on graph contrast learning

    CN117036760A

  • System and method for realizing graph comparison learning model based on community information

    CN117875401A