A code clone detection method based on multi-view graph learning
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-15
- Publication Date
- 2026-08-14
AI Technical Summary
随后通过子图匹配算法提取图特征并计算相似度,但子图匹配属于NP难问题,面对大规模代码库时计算开销呈指数级增长,且仍无法有效处理语义差异较大的Type-4克隆
本发明利用多视图图表示提供链上数据以及共识服务,为系统提供更准确的嵌入、去中心化、可溯源的特点,利用适应滤波和采样策略满足代码分析的企业级场景需求。
Smart Images

Figure CN122569997A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer software engineering technology, specifically to a code clone detection method based on multi-view graph learning. Background Technology
[0002] Currently, code clone detection is essentially a task of identifying functionally similar code snippets, and it has wide applications in software refactoring, bug propagation analysis, plagiarism detection, software maintenance, quality assurance, and code reuse optimization. However, in existing technologies, text-based methods treat code as a sequential token stream, mainly focusing on lexical marker-level information. This makes it difficult to model the structural features and deep semantic relationships of the code, leading to the inability to identify structurally similar but semantically different code pairs, and also misclassifying semantically identical code pairs with different lexical orders. For example, `int c = a + b` and `c = b + a` would be considered different, even though they are semantically identical.
[0003] Structure-based methods represent code snippets using trees or graphs, typically starting with an Abstract Syntax Tree (AST) to encode program structure. However, ASTs only capture syntactic information and cannot fully depict the deep semantic meaning of the program, such as execution logic and data dependencies. Therefore, existing techniques transform code into more complex graph structures, such as Control Flow Graphs (CFGs) or Program Dependency Graphs (PDGs), to better represent execution paths and dependencies. Subgraph matching or Graph Convolutional Networks (GCNs) are then applied to extract code embeddings. However, these methods suffer from the following problems: (1) Text-based methods: These methods treat code as plain text or a sequential token stream, determining clone relationships by calculating text similarity or token sequence matching. While simple to implement and fast, these methods primarily focus on lexical marker-level information, making it difficult to model the structural features and deep semantic relationships of the code. This results in the inability to identify structurally similar but semantically different code pairs, and also misjudgment of semantically identical but lexically different code pairs. For example, `intc=a+b` and `c=b+a` will be considered different code pairs, even though their semantics are completely identical. These methods are only effective at detecting Type-1 clones, with extremely low accuracy for Type-2 and higher clones.
[0004] (2) Structure-based methods: To compensate for the shortcomings of text-based methods in ignoring code structure, these methods represent code fragments using tree or graph structures. Early methods primarily used Abstract Syntax Trees (ASTs) to encode the syntactic structure of programs and calculated similarity using tree matching algorithms. However, ASTs can only capture syntactic-level information and cannot fully depict the deep semantic meaning of the program's execution logic and data dependencies, making it difficult to detect Type-3 and Type-4 clones. Therefore, existing technologies further convert the code into more complex graph structures, such as Control Flow Graphs (CFGs) or Program Dependency Graphs (PDGs). CFGs depict the program's execution path and control transfer relationships, while PDGs simultaneously contain data dependencies and control dependencies, providing a more comprehensive representation of program semantics. Subsequently, subgraph matching algorithms are used to extract graph features and calculate similarity. However, subgraph matching is an NP-hard problem, and its computational cost increases exponentially when dealing with large-scale codebases, and it still cannot effectively handle Type-4 clones with significant semantic differences. Summary of the Invention
[0005] The purpose of this invention is to provide a code clone detection method based on multi-view graph learning to solve the problems mentioned in the background art.
[0006] To achieve the above objectives, the present invention provides the following technical solution: A code clone detection method based on multi-view graph learning includes the following steps: S1. Multi-view graph transformation stage: Obtain the first code segment and the second code segment to be detected, perform lexical analysis and syntax analysis on the first code segment and the second code segment respectively, generate the abstract syntax tree AST, control flow graph CFG and program dependency graph PDG corresponding to each code segment, and construct a code multi-view graph representation set containing three complementary views; S2. Graph Structure Analysis Stage: Perform structural analysis on each view graph in the multi-view graph representation set, extract the syntactic attribute features and semantic association features of the nodes in each view graph and complete the initial vector encoding, label the connection relationship and semantic attributes of different types of edges, and perform size normalization and topology normalization on all view graphs to obtain standardized multi-view graph features. S3, Graph Convolutional Network Processing Stage: A three-branch parallel graph convolutional network architecture is constructed. The standardized abstract syntax tree graph, control flow graph, and data flow graph are input into the corresponding branches. Through multi-layer graph convolution and pooling operations, the local structural features and global context features of each view are extracted. A cross-view attention fusion mechanism is adopted to adaptively calculate the contribution weight of different view features to the clone detection task. The features of the three views are weighted and fused and their dimensions are compressed to generate a global feature vector representing the overall semantics of the code. S4. Similarity Detection Stage: Input the global feature vector corresponding to the first code segment and the global feature vector corresponding to the second code segment into the similarity calculation module to calculate the cosine similarity value between the two global feature vectors; compare the cosine similarity value with a preset clone determination threshold. If the cosine similarity value is greater than or equal to the clone determination threshold, the first code segment and the second code segment are determined to be a code clone pair; otherwise, they are determined to be a non-code clone pair.
[0007] Preferably, the multi-view diagram conversion stage includes: S11. Construct an Abstract Syntax Tree (AST) from source code fragments, where vertices represent syntax elements and edges represent parent-child relationships. S12. Construct a control flow graph (CFG) from source code fragments, where vertices represent statements and control decision points, and edges represent execution semantics. S13. Construct a program dependency graph (PDG) from source code fragments, where vertices represent definition and usage points, and edges represent data and control dependencies. S14. By integrating the Abstract Syntax Tree (AST), Control Flow Graph (CFG), and Program Dependency Graph (PDG) across graph edges, a multi-view code attribute graph (CPG) is formed. The cross-graph edges include AST-to-CFG mapping, AST-to-PDG mapping, and CFG-to-PDG mapping. These edges connect the vertices of different views according to semantic relationships.
[0008] Preferably, the graph structure analysis stage includes: S21. Calculate the degree matrix and normalized Laplacian matrix for each view; S22. Calculate the cross-graph connectivity index and determine the weights accordingly. The cross-graph connectivity index is:
[0009] in, This represents the set of cross-graph edges between view X and view Y. Represents the set of vertices of view X. The set of vertices representing view Y; the weights Using a linear mapping approach based on cross-graph connectivity indices Calculated, i.e. ,in and The weights are preset hyperparameters; This is used to construct a weighted multi-view Laplacian matrix to differentiate and control the intensity of information interaction between different views, thereby strengthening the cross-graph information flow of densely connected data.
[0010] Preferably, the graph convolutional network processing stage includes: S31. Construct a weighted multi-view Laplacian matrix; S32. Apply an adaptive Laplace smoothing filter to perform feature smoothing; S33, Perform view-specific convolutions and degree-weighted aggregations; S34. Perform cross-view fusion to generate unified code embedding.
[0011] Preferably, the adaptive Laplace smoothing filter in step S32 is:
[0012] Where I is the identity matrix, To achieve adaptive smoothing coefficients, dynamic adjustments are made based on local spectral feature analysis of the multi-view graph: for control flow vertices and data-dependent vertices with high degree values, the coefficients are increased. To enhance feature smoothness; for syntactic element vertices with low degree values, reduce To preserve local details; The output of the adaptive Laplace smoothing filter is the smoothed multi-view node feature matrix. Unlike the global uniform transformation of standard GCN, it can adapt to the heterogeneous topology of code graph.
[0013] Preferably, the similarity detection stage includes: S41. Calculate the multi-view similarity score; S42. Adopt an adaptive sampling strategy, adjust the threshold according to code complexity and prioritize hard samples; S43. Determine whether it is a clone based on the similarity score, and classify the clone type.
[0014] Preferably, the multi-view similarity score mentioned in step S41 ,in, The contribution weight for the v-th view. Code snippet for the v-th view With code snippets The intra-view similarity scores and the weights of each view are adaptively learned through a cross-view attention mechanism to avoid over-reliance on a single view. During the similarity calculation, for Type-4 semantic clones, only the matching of their program dependency graph (PDG) semantic view is verified to see if there is a conflict: if the matching degree of data dependency edges and control dependency edges in the PDG views of two code snippets is lower than the preset conflict threshold, it is determined that there is a semantic conflict and it does not belong to Type-4 clones; if the matching degree is higher than or equal to the preset conflict threshold, it is determined that there is no conflict and it meets the semantic matching requirements of Type-4 clones.
[0015] Preferably, the similarity detection stage strictly follows the process sequence constraint: similarity calculation and clone type classification operations are only performed after the graph convolutional network has completed processing and successfully generated the global feature vector corresponding to the code fragment.
[0016] A code clone detection method based on multi-view graph learning, wherein the multi-view graph is any code graph representation, including AST, CFG and PDG views.
[0017] Compared with the prior art, the beneficial effects of the present invention are: This invention utilizes multi-view graph representation to provide on-chain data and consensus services, providing the system with more accurate embedding, decentralization, and traceability. It also uses adaptive filtering and sampling strategies to meet the enterprise-level needs of code analysis. Attached Figure Description
[0018] Figure 1 The attached figure is a schematic diagram illustrating the classification and examples of code clone types in the method provided by this invention.
[0019] Figure 2 The attached figure is a schematic diagram of the overall framework of the method provided by the present invention.
[0020] Figure 3 The attached figure is a schematic diagram comparing the training / detection time in the method provided by the present invention. Detailed Implementation
[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0022] like Figure 1-3 As shown, this embodiment of the invention discloses a code clone detection method based on multi-view graph learning, including the following steps: S1. Multi-view graph transformation stage: Obtain the first and second code segments to be detected, perform lexical analysis and syntax analysis on the first and second code segments respectively, generate the Abstract Syntax Tree (AST), Control Flow Graph (CFG), and Program Dependency Graph (PDG) corresponding to each code segment, and construct a multi-view graph representation set of code containing three complementary views, specifically including: S11. Construct an abstract syntax tree (AST) from source code fragments, where vertices represent syntax elements and edges represent parent-child relationships; S12. Construct a control flow graph (CFG) from source code fragments, where vertices represent statements and control decision points, and edges represent execution semantics; S13. Construct a program dependency graph (PDG) from source code fragments, where vertices represent definition and usage points, and edges represent data and control dependencies; S14. By integrating AST, CFG and PDG across graph edges, a multi-view code attribute graph (CPG) is formed. Cross-graph edges include AST-to-CFG mappings, AST-to-PDG mappings, and CFG-to-PDG mappings, which connect vertices of different views based on semantic relationships.
[0023] S2. Graph Structure Analysis Stage: Structural analysis is performed on each view graph in the multi-view graph representation set. Syntactic attribute features and semantic association features of nodes in each view graph are extracted and initial vector encoding is completed. Connection relationships and semantic attributes of different types of edges are labeled. Simultaneously, size normalization and topological normalization are performed on all view graphs to obtain standardized multi-view graph features, specifically including: S21. Calculate the degree matrix and normalized Laplacian matrix for each view; S22. Calculate the cross-graph connectivity index and determine the weights accordingly. The cross-graph connectivity index is:
[0024] in, This represents the set of cross-graph edges between view X and view Y. Represents the set of vertices of view X. The set of vertices representing view Y; the weights Using a linear mapping approach based on cross-graph connectivity indices Calculated, i.e. ,in and The weights are preset hyperparameters; This is used to construct a weighted multi-view Laplacian matrix to differentiate and control the intensity of information interaction between different views, thereby strengthening the cross-graph information flow of densely connected data.
[0025] S3, Graph Convolutional Network Processing Stage: A three-branch parallel graph convolutional network architecture is constructed. The standardized abstract syntax tree graph, control flow graph, and data flow graph are input into the corresponding branches. Through multi-layer graph convolution and pooling operations, local structural features and global context features of each view are extracted. A cross-view attention fusion mechanism is adopted to adaptively calculate the contribution weights of different view features to the clone detection task. The features of the three views are weighted, fused, and dimensionality compressed to generate a global feature vector representing the overall semantics of the code, specifically including: S31. Construct a weighted multi-view Laplacian matrix; S32. Apply an adaptive Laplace smoothing filter to perform feature smoothing; The adaptive Laplace smoothing filter is:
[0026] Where I is the identity matrix, To achieve adaptive smoothing coefficients, dynamic adjustments are made based on local spectral feature analysis of the multi-view graph: for control flow vertices and data-dependent vertices with high degree values, the coefficients are increased. To enhance feature smoothness; for syntactic element vertices with low degree values, reduce To preserve local details; The output of the adaptive Laplace smoothing filter is the smoothed multi-view node feature matrix. Unlike the global uniform transformation of standard GCN, it can adapt to the heterogeneous topology of code graph; S33, Perform view-specific convolutions and degree-weighted aggregations; S34. Perform cross-view fusion to generate unified code embedding.
[0027] S4. Similarity Detection Stage: The global feature vectors corresponding to the first code segment and the second code segment are input into the similarity calculation module to calculate the cosine similarity value between the two global feature vectors. The cosine similarity value is compared with a preset clone determination threshold. If the cosine similarity value is greater than or equal to the clone determination threshold, the first code segment and the second code segment are determined to be a code clone pair; otherwise, they are determined to be a non-code clone pair. Specifically, this includes: S41. Calculate the multi-view similarity score: Multi-view similarity score ,in, The contribution weight for the v-th view. Code snippet for the v-th view With code snippets The intra-view similarity scores and the weights of each view are adaptively learned through a cross-view attention mechanism to avoid over-reliance on a single view. During the similarity calculation, for Type-4 semantic clones, only the matching of their program dependency graph (PDG) semantic view is verified to see if there is a conflict: if the matching degree of data dependency edges and control dependency edges in the PDG views of two code snippets is lower than the preset conflict threshold, it is determined that there is a semantic conflict and it does not belong to Type-4 clones; if the matching degree is higher than or equal to the preset conflict threshold, it is determined that there is no conflict and it meets the semantic matching requirements of Type-4 clones. S42. Adopt an adaptive sampling strategy, adjust the threshold according to code complexity and prioritize hard samples; S43. Determine whether it is a clone based on the similarity score and classify the clone type: After the similarity detection stage waits for the graph convolutional network to process and generate the embedding, the clone judgment is classified to ensure the atomicity of the detection to modify the multi-view embedding, so that the state modification of the embedding and the state modification of the clone classification are consistent.
[0028] This embodiment is a code clone detection method based on multi-view graph learning. The embodiment includes four entities: source code fragments, multi-view graph construction module, graph convolutional network module, and similarity detection module.
[0029] 1. The source code snippets in the embodiments are no different from ordinary code clone detection inputs; both can be implemented using function or method snippets. However, the following operations and structures of the code need to be modified: (1) Code snippets can generate multi-view graphs, so different structures need to be designed for the views. The multi-view graph needs to include the syntax elements of the AST view, the execution path of the CFG view, and the data dependencies of the PDG view.
[0030] (2) Since the available views and cross-graph edges in the system are uncertain, an appropriate integration strategy needs to be designed before the transformation, depending on the current situation. Usually, only basic mappings are needed, rather than complex connections.
[0031] 2. In this embodiment, the multi-view graph construction module can be implemented by modifying existing code parsing tools. This method uses an abstract syntax tree parser as the basis and modifies its original structure as follows: (1) After receiving the code snippet, the original parser first checks the syntax structure. If it passes the check, it generates the AST, and finally generates the CFG and PDG. For multiple views, after the AST is generated, the views and their related cross edges need to be integrated into the CPG.
[0032] (2) In the structural analysis stage, in order to ensure the heterogeneous processing of multiple views, it is necessary to calculate the connectivity weight after the analysis is completed, so as to ensure the accuracy of view fusion.
[0033] 3. In this embodiment, the graph convolutional network module can be composed of PyTorch or TensorFlow frameworks. The services that the graph convolutional network needs to implement include: (1) Since graph convolutional networks need to receive structural information and smoothing results from multi-view graphs, and also need to send embeddings to the similarity module, a communication service needs to be built with the multi-view module. The communication service can be implemented in various ways, such as data streams.
[0034] (2) The graph convolutional network should be linked to the adaptive filter and have the authority to dynamically adjust the filter parameters. Taking the adaptive Laplace filter mentioned in this invention as an example, the graph convolutional network can perform correlation operations on k_MV through spectral analysis.
[0035] (3) Graph convolutional networks should be able to process multi-view data based on degree weighting to obtain a unified embedding.
[0036] 4. In principle, the similarity detection module in the embodiment can use various similarity calculations. However, in order to meet the needs of semantic clone detection and provide high accuracy and low overhead for complex scenarios, this invention adopts multi-view similarity and adaptive sampling.
[0037] The relationships and data exchanges between the aforementioned entities are as follows: Figure 2 As shown, the following sections will elaborate on the overall process details of the system based on the system's multi-view diagram conversion stage and diagram structure analysis stage.
[0038] After the initialization of each entity is completed, the overall process of the multi-view diagram conversion phase is as follows: Figure 2 As shown in (a), the specific implementation method will be described in detail below with reference to the flowchart and the embodiments.
[0039] 1. First, the multi-view graph construction module needs to build a communication service. Taking a data pipeline as an example, the communication service can be built as a client in the code parser and a server in the graph convolutional network. Since each view is independent, there's no need to use a streaming service; simple data transfer is sufficient.
[0040] 2. If the required code parser has not yet been deployed, you need to write the parsing logic and deploy it in accordance with the relevant rules.
[0041] 3. Users construct views according to their needs using methods provided by the source code snippets. Views are divided into three categories: AST, CFG, and PDG. As mentioned above, multiple views need to include syntax elements, execution paths, and data dependencies.
[0042] 4. The multi-view construction module needs to perform different processing flows for the three types of views. For AST views, they are generated according to the standard parsing process. For CFG and PDG views, control flow and dependency graphs need to be generated based on the AST.
[0043] 5. After the view is generated, it needs to be further divided into integration operations based on the operation type: The integration operation steps are as follows: (1.1) Add cross-graph edges based on semantic relationships, such as AST-to-CFG.
[0044] (1.2) Form a unified CPG.
[0045] (1.3) Send the CPG to the graph structure analysis module.
[0046] For integration operations, sending the CPG to the next stage after completion, without additional storage, can protect the privacy of the code structure and the security of processing.
[0047] 6. After receiving the CPG, the structure analysis module calculates the degree matrix, Laplacian weights, and connectivity weights, and sends the results to the graph convolutional network.
[0048] Once the structural analysis is complete, the results are sent to the graph convolutional network for processing. The overall process is as follows: Figure 2 As shown in (b), the specific implementation method will be described in detail below with reference to the flowchart and the embodiments.
[0049] 1. When a graph convolutional network receives the structural analysis results, it needs to determine the weights according to the fusion strategy. For multiple views, the fusion strategy is often relatively simple, usually requiring only weighted summation.
[0050] 2. After the result satisfies the strategy, the graph convolutional network applies a smoothing filter to the Laplacian. When applying the filter, no distinction is made between views; all views are processed according to the same rules.
[0051] 3. Convolutions are performed on each view, processing view-specific convolutions and degree-weighted aggregations, and reducing noise if present. In this aggregation, contributions from high- and low-degree vertices are balanced without additional validation.
[0052] 4. If the processing passes, the graph convolutional network will generate a unified embedding based on the fusion. If the processing fails, no operation will be performed on the embedding.
[0053] 5. Regardless of whether the processing succeeds or fails, the graph convolutional network will send a result message to the similarity detection module after completion. If the similarity module receives a success message, it will calculate the score based on the saved embeddings. If the similarity module receives a failure message, it will discard the saved results and not perform any calculations. This method ensures the atomicity of modifications to the embeddings and similarity calculations.
[0054] 6. This concludes the complete lifecycle of a code clone detection.
[0055] This invention constructs a code clone detection mechanism based on multi-view graph learning, helping software engineers avoid the low accuracy and high computational cost of Type-3 and Type-4 clone detection. It enables detection systems to more easily identify semantically similar code through multi-view fusion. The multi-view graph used provides heterogeneous structure capture and generalization capabilities, while adaptive filtering offers a solution for addressing heterogeneous scenarios. This invention proposes a more accurate and efficient solution for code clone detection.
[0056] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A code clone detection method based on multi-view graph learning, characterized in that, Includes the following steps: S1. Multi-view graph transformation stage: Obtain the first code segment and the second code segment to be detected, perform lexical analysis and syntax analysis on the first code segment and the second code segment respectively, generate the abstract syntax tree AST, control flow graph CFG and program dependency graph PDG corresponding to each code segment, and construct a code multi-view graph representation set containing three complementary views; S2. Graph Structure Analysis Stage: Perform structural analysis on each view graph in the multi-view graph representation set, extract the syntactic attribute features and semantic association features of the nodes in each view graph and complete the initial vector encoding, label the connection relationship and semantic attributes of different types of edges, and perform size normalization and topology normalization on all view graphs to obtain standardized multi-view graph features. S3, Graph Convolutional Network Processing Stage: Construct a three-branch parallel graph convolutional network architecture, input the standardized abstract syntax tree graph, control flow graph, and data flow graph into the corresponding branches, and extract the local structural features and global context features of each view through multi-layer graph convolution and pooling operations; A cross-view attention fusion mechanism is adopted to adaptively calculate the contribution weight of different view features to the clone detection task, and perform weighted fusion and dimensionality compression on the features of the three views to generate a global feature vector that represents the overall semantics of the code. S4. Similarity Detection Stage: Input the global feature vector corresponding to the first code segment and the global feature vector corresponding to the second code segment into the similarity calculation module to calculate the cosine similarity value between the two global feature vectors; compare the cosine similarity value with a preset clone determination threshold. If the cosine similarity value is greater than or equal to the clone determination threshold, the first code segment and the second code segment are determined to be a code clone pair; otherwise, they are determined to be a non-code clone pair.
2. The code clone detection method based on multi-view graph learning according to claim 1, characterized in that, The multi-view diagram conversion stage includes: S11. Construct an Abstract Syntax Tree (AST) from source code fragments, where vertices represent syntax elements and edges represent parent-child relationships. S12. Construct a control flow graph (CFG) from source code fragments, where vertices represent statements and control decision points, and edges represent execution semantics. S13. Construct a program dependency graph (PDG) from source code fragments, where vertices represent definition and usage points, and edges represent data and control dependencies. S14. By integrating the Abstract Syntax Tree (AST), Control Flow Graph (CFG), and Program Dependency Graph (PDG) across graph edges, a multi-view code attribute graph (CPG) is formed. The cross-graph edges include AST-to-CFG mapping, AST-to-PDG mapping, and CFG-to-PDG mapping. These edges connect the vertices of different views according to semantic relationships.
3. The code clone detection method based on multi-view graph learning according to claim 1, characterized in that, The graph structure analysis phase includes: S21. Calculate the degree matrix and normalized Laplacian matrix for each view; S22. Calculate the cross-graph connectivity index and determine the weights accordingly. The cross-graph connectivity index is: in, This represents the set of cross-graph edges between view X and view Y. Represents the set of vertices of view X. The set of vertices representing view Y; the weights Using a linear mapping approach based on cross-graph connectivity indices Calculated, i.e. ,in and The weights are preset hyperparameters; This is used to construct a weighted multi-view Laplacian matrix to differentiate and control the intensity of information interaction between different views, thereby strengthening the cross-graph information flow of densely connected data.
4. The code clone detection method based on multi-view graph learning according to claim 1, characterized in that, The graph convolutional network processing stage includes: S31. Construct a weighted multi-view Laplacian matrix; S32. Apply an adaptive Laplace smoothing filter to perform feature smoothing; S33, Perform view-specific convolutions and degree-weighted aggregations; S34. Perform cross-view fusion to generate unified code embedding.
5. The code clone detection method based on multi-view graph learning according to claim 4, characterized in that, The adaptive Laplace smoothing filter mentioned in step S32 is: Where I is the identity matrix, To achieve adaptive smoothing coefficients, dynamic adjustments are made based on local spectral feature analysis of the multi-view graph: for control flow vertices and data-dependent vertices with high degree values, the coefficients are increased. To enhance feature smoothness; for syntactic element vertices with low degree values, reduce To preserve local details; The output of the adaptive Laplace smoothing filter is the smoothed multi-view node feature matrix. Unlike the global uniform transformation of standard GCN, it can adapt to the heterogeneous topology of code graph.
6. The code clone detection method based on multi-view graph learning according to claim 1, characterized in that, The similarity detection stage includes: S41. Calculate the multi-view similarity score; S42. Adopt an adaptive sampling strategy, adjust the threshold according to code complexity and prioritize hard samples; S43. Determine whether it is a clone based on the similarity score, and classify the clone type.
7. The code clone detection method based on multi-view graph learning according to claim 6, characterized in that, The multi-view similarity score mentioned in step S41 ,in, The contribution weight for the v-th view. Code snippet for the v-th view With code snippets The intra-view similarity scores and the weights of each view are adaptively learned through a cross-view attention mechanism to avoid over-reliance on a single view. During the similarity calculation, for Type-4 semantic clones, only the matching of their program dependency graph (PDG) semantic view is verified to see if there is a conflict: if the matching degree of data dependency edges and control dependency edges in the PDG views of two code snippets is lower than the preset conflict threshold, it is determined that there is a semantic conflict and it does not belong to Type-4 clones; if the matching degree is higher than or equal to the preset conflict threshold, it is determined that there is no conflict and it meets the semantic matching requirements of Type-4 clones.
8. The code clone detection method based on multi-view graph learning according to claim 1, characterized in that, The similarity detection stage strictly follows the process sequence constraint: similarity calculation and clone type classification operations are only performed after the graph convolutional network has completed processing and successfully generated the global feature vector corresponding to the code fragment.
9. The code clone detection method based on multi-view graph learning according to any one of claims 1-8, characterized in that, The multi-view diagram can be any type of code diagram representation, including AST, CFG, and PDG views.