软件导刊2026,Vol.25Issue(6):48-55,8.DOI:10.11907/rjdk.241789
基于图神经网络的相似性代码检测方法
Code Similarity Detection Method Based on Graph Neural Network
摘要
Abstract
To address the shortcomings of existing code similarity detection methods in terms of semantic representation capabilities,this pa-per proposes a code similarity analysis method based on graph neural networks.Existing techniques are generally categorized into text-based,lexical unit-based,syntactic structure-based,and program dependency-based methods,but most focus on single-level feature representa-tion,failing to effectively capture deep semantic information during program execution.To solve this problem,this paper constructs a graph representation model that integrates syntactic structure and program behavior features.Specifically,based on an abstract syntax tree frame-work,the original tree structure is expanded by introducing control dependency edges and data dependency edges,thus forming a program graph representation containing multiple types of relationships.On this basis,a graph neural network is used to learn the representation of code fragments,obtaining vectorized representations of the code through information propagation and aggregation between nodes,and using co-sine similarity to measure the similarity of different code fragments.This method can simultaneously characterize the structural features and se-mantic information of the program,thereby improving the ability to identify complex code similarities.Experimental results show that the pro-posed method has better performance in semantic similarity detection tasks compared to traditional methods.关键词
图神经网络/代码相似性检测/数据流/控制流Key words
graph neural network/similarity code detection/data flow/control flow分类
信息技术与安全科学引用本文复制引用
赵涵,崔博夕,张卫丰..基于图神经网络的相似性代码检测方法[J].软件导刊,2026,25(6):48-55,8.基金项目
国家自然科学基金面上项目(62272214) (62272214)
南京市国际合作项目(202401006) (202401006)