Thursday, November 12, 2026
Science
No Result
View All Result
  • Login
  • HOME
  • SCIENCE NEWS
  • CONTACT US
  • HOME
  • SCIENCE NEWS
  • CONTACT US
No Result
View All Result
Scienmag
No Result
View All Result
Home Science News Technology and Engineering

Intelligent Source Code Clustering Achieves High Accuracy Using Graph Embedding and Adaptive Hierarchies

November 12, 2026
in Technology and Engineering
Denise Maddox
By Denise Maddox Scienmag Editorial Profile - Mechanical Engineering
Reading Time: 7 mins read
0
Intelligent Source Code Clustering Achieves High Accuracy Using Graph Embedding and Adaptive Hierarchies

Intelligent Source Code Clustering Achieves High Accuracy Using Graph Embedding and Adaptive Hierarchies

65
SHARES
587
VIEWS
Share on FacebookShare on Twitter
ADVERTISEMENT

Software engineering teams and academic institutions invest substantial resources into auditing source code, managing code quality, and verifying that program implementations follow required functional logic without errors. In traditional software development workflows, dedicated testing engineers conduct repetitive manual inspections and unit testing to ensure programs align with expected operational requirements. To automate these laborious workflows and reduce engineering overhead, researchers have developed an intelligent source code evaluation system that transforms raw programming scripts into structured graph representations, vectorizes them through graph embedding algorithms, and partitions the resulting feature spaces using contrastive learning and unsupervised hierarchical clustering. In experimental evaluations conducted on structured C language programs, the proposed framework successfully distinguished correct implementations from erroneous submissions without requiring manual supervisory classification rules during clustering, reaching an optimal silhouette score of 0.8804 and a Davies-Bouldin index of 0.0822 when separating code samples into binary clusters.

The motivation behind the automated evaluation framework stems from common patterns in software development, where diverse developers implement applications that fulfill identical or highly similar business logic. Typical commercial systems, such as enterprise attendance loggers or routine transactional modules, frequently share underlying structural and operational principles across independent deployments. Because these functional targets remain consistent across different implementations, automated systems can evaluate unassessed code by comparing its structural syntax against trusted reference programs or high-quality benchmark samples written by technical specialists. When software testing platforms accumulate sufficient quantities of reliable reference code, automated evaluation engines can assess whether newly submitted code achieves the requisite functional goals. Previous research explored supervised deep learning architectures, such as tree-based convolutional neural networks, gated graph neural networks, and hybrid program graphs, to detect abnormal code structures by minimizing classification loss against labeled training sets. However, supervised strategies depend heavily on extensive manual data labeling, which introduces human cognitive bias, inconsistent auditing criteria, and high labor costs that undermine system scalability.

To overcome the limitations of manual labeling and supervised training, the research team designed an end-to-end evaluation pipeline that converts unstructured source code into computable mathematical structures before applying unsupervised machine learning. The overall system architecture comprises five integrated modules: automated data collection, graph generation, graph embedding, optional dimensionality reduction, and an optimization and clustering module. In the data ingestion stage, automated web driver scripts retrieve code submissions from management platforms, pulling diverse program versions alongside intermediate testing metrics. For the structural transformation stage, the pipeline relies on Abstract Syntax Trees to capture lexical and grammatical program components in a standardized hierarchical tree structure. While compiler-level Control Flow Graphs can capture execution paths across basic blocks, the empirical implementation specifically deployed Abstract Syntax Trees generated through the open-source Tree-sitter parsing library. Tree-sitter utilizes preconfigured grammar rules and language libraries to tokenize source scripts into syntax trees, exporting symbolic S-expressions and standardized DOT files that accurately map programming nodes and relationships.

Converting parsed syntax trees into numerical representations suitable for machine learning algorithms requires robust graph embedding methodologies. Abstract Syntax Trees contain high-dimensional, non-smooth relational data consisting of syntax nodes, connecting edges, lexical attributes, and hierarchical dependencies that cannot be directly ingested by standard numerical clustering models. The researchers addressed this by deploying the Graph2vec embedding framework, which transforms full-graph structures into continuous low-dimensional vector representations. The graph embedding algorithm initializes by extracting rooted subgraphs around each individual node in the program tree using the Weisfeiler-Lehman relabeling procedure up to a specified depth of two. This recursive traversal records the structural context and neighboring node configurations across the entire syntax tree. The resulting subgraphs are subsequently processed across five training epochs with a learning rate of 0.025 to generate a dense 256-dimensional vector embedding for each program script, producing standardized numerical matrices that capture the global semantic and grammatical features of the original source code files.

Although Graph2vec generates fixed-size vector matrices representing complete program files, the initial embedding values tend to concentrate tightly within a narrow range between negative 0.2 and positive 0.2. This numerical compression prevents standard analytical algorithms from isolating fine-grained structural discrepancies between distinct source code submissions. To expand the feature distributions and emphasize subtle programmatic differences, the researchers introduced an optimization stage governed by an adapted contrastive loss framework. Contrastive learning relies on pulling representations of positive samples closer together while simultaneously pushing negative samples farther apart in the latent embedding space. In standard machine learning applications, contrastive objectives like InfoNCE rely exclusively on cosine similarity to compare representations. While cosine similarity effectively evaluates directional alignment across structural, branching, and semantic patterns, it fails to differentiate samples characterized by variations in absolute code length, redundancy factors, or total abstract syntax tree node counts.

To remedy the blind spots of conventional directional metrics, the authors engineered a hybrid-weight similarity measurement function that integrates cosine similarity with an inverse Euclidean distance formulation. In this hybrid formulation, the similarity between two embedding vectors is calculated as the sum of a weighted cosine similarity component and an adjusted L2-distance Euclidean component scaled by a hyperparameter lambda. Normalizing the weighting coefficients ensures balanced contributions from both structural angle alignment and geometric distance in the feature space. To validate the mathematical superiority of this hybrid function before applying it to full clustering workflows, the team conducted preliminary optimization experiments using a K-Nearest Neighbors classifier applied to a randomized subset of 300 program samples, consisting of 246 positive implementations and 54 negative implementations. Under default parameter settings with equal weighting, the baseline L2-distance Euclidean formulation achieved an accuracy of 0.8533 and an F1 score of 0.9170 at k equals 7, outperforming plain cosine similarity.

Subsequent coarse-grained grid searches across hyperparameter configurations revealed that fine-tuning the hybrid-weight similarity parameters significantly improved evaluation performance over either individual metric. Specifically, setting the cosine weight alpha to 0.1, the Euclidean weight beta to 0.9, and the distance scaling coefficient lambda to 1.0 with a neighborhood size of 9 elevated the classification performance of the KNN model, confirming that integrating geometric distance with directional alignment yields superior code discrimination. The optimized similarity metric was then incorporated directly into an improved InfoNCE contrastive loss function. This formulation maps anchor samples against positive reference sets and negative sets, utilizing a temperature tuning coefficient to adjust the sharpness of the resulting similarity distribution. The researchers also formulated an extended objective that introduces a penalty coefficient gamma to punish abnormal sample behaviors, such as positive samples drifting far from reference anchors or negative samples intruding near reference points, while reserving full implementation of the anchor penalty term for future investigations.

The experimental validation of the complete pipeline utilized a dedicated dataset of C-language source code files collected from programming course quizzes stored in a MySQL database. While the raw database repository contained approximately 100,000 student code submissions totaling 500 megabytes of storage, institutional data usage authorizations restricted the experimental dataset to 879 distinct code samples compliant with the C99 language standard. To prevent labeling inconsistencies and subjective scoring variance across the study, all sample annotations were conducted by a single teaching assistant. Submissions were designated as positive samples if they met three strict criteria: generating completely correct execution outputs, satisfying runtime and memory consumption limits, and completing standard source code preprocessing. Programs failing any single criterion were designated as negative samples. In total, the experimental collection contained 701 positive samples, one high-quality expert benchmark sample, and 177 negative samples, with no artificial data augmentation or train-test partitioning applied due to the unsupervised nature of the primary clustering task.

For final code quality grading and partitioning, the embedded and optimized representations were processed through an adaptive hierarchical clustering algorithm. Unlike traditional clustering techniques such as K-Means or Deep Embedding Clustering, hierarchical clustering does not require researchers to predefine an arbitrary number of clusters prior to execution. Instead, the algorithm iteratively constructs an intuitive cluster tree, generating dendrograms that expose natural sample distributions while allowing optimal partitioning thresholds to be selected post hoc based on formal clustering validity indices. Dimensionality reduction algorithms, such as Principal Component Analysis, t-Distributed Stochastic Neighbor Embedding, or Uniform Manifold Approximation and Projection, were designated as optional components within the architecture. Because computational resources were sufficient to process the full 256-dimensional Graph2vec matrices directly, dimensionality reduction was utilized solely for multi-view visualization rather than feature truncation.

The performance of the proposed framework was comprehensively benchmarked against standard unsupervised clustering algorithms, including K-Means, Deep Embedding Clustering (DEC), and Deep Attentional Embedded Graph Clustering (DAEGC), using the complete 879-sample dataset. Evaluation quality was measured using the silhouette score, where higher values denote denser and more distinct clusters, and the Davies-Bouldin index, where lower values signify superior cluster separation. Classical unsupervised algorithms struggled to isolate erroneous code from correct submissions cleanly; for example, baseline K-Means achieved lower silhouette scores and higher separation error across varying cluster numbers. In contrast, the researchers’ optimal algorithm combining the hybrid-weight InfoNCE function with adaptive hierarchical clustering achieved clear separation matching the underlying ground-truth data distribution. At a binary cluster division of k equals 2, the system achieved a silhouette score of 0.8804 and an exceptionally low Davies-Bouldin index of 0.0822, significantly outperforming both classical baselines and versions operating with standard cosine-based InfoNCE functions.

Despite these favorable experimental results, the authors emphasized several technical limitations and outlined key avenues for ongoing refinement. While the system demonstrated robust binary separation between valid and invalid programming quiz submissions, enterprise software quality management requires fine-grained, multi-dimensional assessment beyond pass-fail categorization. Future developments aim to incorporate comprehensive software engineering metrics into the decision framework, including cyclomatic complexity, maintainability indices, lines of code, class coupling, depth of inheritance trees, and fan-in and fan-out measurements. Additionally, the experimental deployment focused on Abstract Syntax Trees from C-language submissions, leaving the integration of Control Flow Graphs and deep learning foundation models, such as CodeBERT, GraphCodeBERT, and gated graph neural networks, for subsequent comparative investigations. Nevertheless, the study confirms that pairing graph-based syntax tree embeddings with hybrid contrastive loss optimization and adaptive hierarchical clustering provides a viable, mathematically grounded architecture for automated source code evaluation in software development environments.

Subject of Research: Automated evaluation and unsupervised clustering of computer source code using graph embeddings and contrastive learning

Article Title: Research on intelligent evaluation system of program algorithms used in IT development process

Article References: Ma, W., Yu, H., & Zhang, X. (2026). Research on intelligent evaluation system of program algorithms used in IT development process. Discover Computing, 29(1), Article 877. https://doi.org/10.1007/s10791-026-10744-3

Image Credits: AI Generated

DOI: 10.1007/s10791-026-10744-3

Keywords: source code evaluation, abstract syntax tree, graph embedding, Graph2vec, unsupervised clustering, hierarchical clustering, InfoNCE loss, contrastive learning, Weisfeiler Lehman algorithm, software testing, Tree sitter, cosine similarity, Euclidean distance, silhouette score, Davies Bouldin index, software quality management, program analysis

Cite Scienmag News

Denise Maddox. (November 12, 2026). Intelligent Source Code Clustering Achieves High Accuracy Using Graph Embedding and Adaptive Hierarchies. Scienmag. https://scienmag.com/intelligent-source-code-clustering-achieves-high-accuracy-using-graph-embedding-and-adaptive-hierarchies/

Denise Maddox. "Intelligent Source Code Clustering Achieves High Accuracy Using Graph Embedding and Adaptive Hierarchies." Scienmag, 12 November 2026, https://scienmag.com/intelligent-source-code-clustering-achieves-high-accuracy-using-graph-embedding-and-adaptive-hierarchies/. Accessed 12 November 2026.

Denise Maddox. "Intelligent Source Code Clustering Achieves High Accuracy Using Graph Embedding and Adaptive Hierarchies." Scienmag. November 12, 2026. https://scienmag.com/intelligent-source-code-clustering-achieves-high-accuracy-using-graph-embedding-and-adaptive-hierarchies/

Tags: abstract syntax treecontrastive learningcosine similarityDavies Bouldin indexEuclidean distancegraph embeddingGraph2vechierarchical clusteringInfoNCE lossprogram analysisSilhouette Scoresoftware quality managementsoftware testingsource code evaluationTree-sitterunsupervised clusteringWeisfeiler Lehman algorithm
Share26Tweet16
Previous Post

SmartQSM Improves 3D Structure Modeling in Dormant Orchard Walnut Trees

Next Post

Green Liquid Chromatography Method Quantifies Ascorbic Acid Across Nutraceutical Dosage Forms

Related Posts

BactFlow Provides Graphical Workflow for Bacterial Genome Assembly and Annotation
Biotechnology

BactFlow Provides Graphical Workflow for Bacterial Genome Assembly and Annotation

November 12, 2026
Open-Source P4Struct Framework Integrates Complete Topology Optimization and Mesh Export Workflows
Technology and Engineering

Open-Source P4Struct Framework Integrates Complete Topology Optimization and Mesh Export Workflows

November 12, 2026
Enhanced Particle Swarm Algorithm Boosts Mixed Delivery Fleet Routing Efficiency
Technology and Engineering

Enhanced Particle Swarm Algorithm Boosts Mixed Delivery Fleet Routing Efficiency

November 12, 2026
Non-Isothermal Isotope Model Accurately Evaluates Gas Content in Deep Reservoirs
Technology and Engineering

Non-Isothermal Isotope Model Accurately Evaluates Gas Content in Deep Reservoirs

November 12, 2026
Cerium Oxide Refines Microstructure and Increases Hardness in Laser-Clad High-Entropy Coatings
Technology and Engineering

Cerium Oxide Refines Microstructure and Increases Hardness in Laser-Clad High-Entropy Coatings

November 12, 2026
Solar-Assisted Triple Nanofluid Model Demonstrates Enhanced Heat Transfer Under Oblique Flow
Technology and Engineering

Solar-Assisted Triple Nanofluid Model Demonstrates Enhanced Heat Transfer Under Oblique Flow

November 12, 2026
Next Post
Green Liquid Chromatography Method Quantifies Ascorbic Acid Across Nutraceutical Dosage Forms

Green Liquid Chromatography Method Quantifies Ascorbic Acid Across Nutraceutical Dosage Forms

  • Mothers who receive childcare support from maternal grandparents show more optimized

    Mothers who receive childcare support from maternal grandparents show more parental warmth, finds NTU Singapore study

    27656 shares
    Share 11059 Tweet 6912
  • University of Seville Breaks 120-Year-Old Mystery, Revises a Key Einstein Concept

    1061 shares
    Share 424 Tweet 265
  • Bee body mass, pathogens and local climate influence heat tolerance

    682 shares
    Share 273 Tweet 171
  • Researchers record first-ever images and data of a shark experiencing a boat strike

    546 shares
    Share 218 Tweet 137
  • Groundbreaking Clinical Trial Reveals Lubiprostone Enhances Kidney Function

    531 shares
    Share 212 Tweet 133
Science

Embark on a thrilling journey of discovery with Scienmag.com—your ultimate source for cutting-edge breakthroughs. Immerse yourself in a world where curiosity knows no limits and tomorrow’s possibilities become today’s reality!

RECENT NEWS

  • Model Disentangles Leaf Day Respiration From Photorespiration in Four C3 Crops
  • Models Suggest US Drinking Water May Harbor Double Reported PFAS Concentrations
  • Asia-Pacific Study Finds Most Long COVID Risks Subside After One Year
  • Hybrid Radiomics Model Accurately Identifies Small Cell Lung Cancer in Peripheral Nodules

Categories

  • Agriculture
  • Anthropology
  • Archaeology
  • Athmospheric
  • Biology
  • Biotechnology
  • Blog
  • Bussines
  • Cancer
  • Chemistry
  • Climate
  • Earth Science
  • Editorial Policy
  • Marine
  • Mathematics
  • Medicine
  • Pediatry
  • Policy
  • Psychology & Psychiatry
  • Science Education
  • Science News
  • Social Science
  • Space
  • Technology and Engineering

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 5,150 other subscribers

© 2026 Scienmag - Science Magazine

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result
  • HOME
  • SCIENCE NEWS
  • CONTACT US

© 2026 Scienmag - Science Magazine

Discover more from Science

Subscribe now to keep reading and get access to the full archive.

Continue reading