Inferensys

Glossary

Graph Classification

Graph classification is a supervised machine learning task that predicts a categorical label for an entire graph based on its structural features and node/edge attributes.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
GRAPH ANALYTICS FOR BUSINESS INTELLIGENCE

What is Graph Classification?

Graph classification is a supervised machine learning task where the goal is to predict a categorical label for an entire graph based on its structural features and node or edge attributes.

Graph classification is a supervised machine learning task where the goal is to predict a categorical label for an entire graph based on its structural features and node or edge attributes. This differs from node classification, which assigns labels to individual nodes. The task requires learning a function that maps an entire graph structure—including its adjacency matrix, node features, and edge types—to a discrete class. It is a fundamental problem in graph data mining with applications in molecular property prediction, social network analysis, and document categorization.

Common approaches include graph kernel methods, which compute similarity measures between graphs for use with traditional classifiers like SVMs, and graph neural networks (GNNs), which learn hierarchical representations via message passing. Key challenges involve designing models that are invariant to graph isomorphisms (node permutations) and can handle graphs of varying sizes and complexities. Performance is evaluated using standard classification metrics like accuracy, precision, and recall on held-out test sets of graphs.

GRAPH ANALYTICS FOR BUSINESS INTELLIGENCE

Key Features of Graph Classification

Graph classification is a supervised learning task where the goal is to predict a class label for an entire graph based on its structural features and node/edge attributes. It is distinct from node or link classification, as it assigns a label to the entire network structure.

01

Whole-Graph Representation Learning

The core challenge is to learn a fixed-size vector representation (an embedding) for an entire graph of variable size and structure. This is achieved through graph pooling or readout functions that aggregate node-level features learned by a Graph Neural Network (GNN). Common techniques include:

  • Global mean/max/sum pooling: Simple aggregation of all node embeddings.
  • Hierarchical pooling: Learns to coarsen the graph iteratively, preserving hierarchical structure.
  • SortPooling: Sorts node features to create a fixed-length sequence for a 1D convolutional layer. The resulting graph-level embedding is then fed into a standard classifier (e.g., a multilayer perceptron).
02

Structural Feature Extraction

Effective classification relies on capturing the graph's topological properties, which go beyond simple node attributes. Key structural features include:

  • Global graph statistics: Diameter, average path length, density, and assortativity.
  • Subgraph patterns: Counts of specific motifs (e.g., triangles, stars) or graphlets.
  • Spectral features: Derived from the eigenvalues and eigenvectors of the graph's Laplacian matrix, capturing connectivity properties.
  • Centrality distributions: The distribution of node importance scores (e.g., betweenness, eigenvector centrality) across the graph. These features can be used directly in traditional classifiers (e.g., Random Forests) or as complementary signals to GNNs.
03

Invariance to Graph Isomorphism

A fundamental requirement for a graph classification model is permutation invariance. The predicted label must not change if the nodes of the input graph are re-ordered (i.e., the graph is isomorphic). This is a non-trivial constraint for neural networks. Solutions include:

  • Using symmetric pooling functions: Sum, mean, and max are inherently permutation-invariant aggregation operations.
  • Designing GNN layers with shared parameters: Message-passing GNNs apply the same transformation to each node, making them inherently equivariant to node ordering.
  • Graph kernels: Kernel methods like the Weisfeiler-Lehman (WL) subtree kernel explicitly compare graphs in an isomorphism-invariant manner by iteratively hashing neighborhood structures.
04

Hierarchical and Multi-Scale Modeling

Important patterns for classification often exist at multiple scales within a graph. Modern architectures capture this through hierarchical processing:

  • Stacked GNN layers: Each layer aggregates information from a larger neighborhood (K-hop). Deeper layers capture more global structure.
  • Differentiable pooling (DiffPool): Learns to assign nodes to clusters in a soft, hierarchical manner, creating a coarsened graph at each layer.
  • Jumping Knowledge Networks: Combine representations from all GNN layers, allowing the final classifier to access both local and global features. This multi-scale approach is critical for distinguishing graphs where the defining characteristic is a specific subgraph (local) versus the overall connectivity pattern (global).
05

Handling Heterogeneous Graphs

Real-world business graphs often contain multiple node and edge types (e.g., in a knowledge graph: Customer, Product, Transaction). Heterogeneous Graph Neural Networks (HGNNs) extend GNNs for this complex data:

  • Type-specific transformations: Use different weight matrices for messages passed along different relation types.
  • Meta-paths: Predefined sequences of node/edge types (e.g., User -buys-> Product -bought_by-> User) are used to guide attention and aggregation.
  • Heterogeneous graph transformers: Apply transformer-style attention mechanisms across nodes and edges of different types. This allows classification of complex enterprise networks, such as categorizing a supply chain graph by its risk profile or a social network by its community structure type.
06

Business Intelligence Applications

Graph classification translates structural business data into actionable categories. Key enterprise use cases include:

  • Financial Fraud Detection: Classifying transaction networks as fraudulent or legitimate based on the connectivity patterns between accounts and entities.
  • Molecular Property Prediction: In drug discovery, classifying molecular graphs (atoms=nodes, bonds=edges) by their toxicity or bioactivity.
  • Document Categorization: Representing a corpus as a graph of terms (nodes) and their co-occurrence (edges) to classify document topics.
  • Supply Chain Risk Assessment: Classifying a supplier network graph as high, medium, or low risk based on its centrality, redundancy, and geographic dispersion.
  • Social Network Analysis: Categorizing online community graphs by their primary function (e.g., support, interest-based, professional).
TASK COMPARISON

Graph Classification vs. Related Tasks

A comparison of the supervised graph-level prediction task against other core graph learning and analytics tasks.

Task / FeatureGraph ClassificationNode ClassificationLink PredictionCommunity Detection

Primary Objective

Predict a label for an entire graph.

Predict a label or property for individual nodes.

Predict the existence or strength of a missing edge between two nodes.

Identify densely connected groups of nodes (clusters).

Learning Paradigm

Supervised learning

Supervised or semi-supervised learning

Supervised or self-supervised learning

Unsupervised learning

Input Unit

A whole graph (multiple graphs in a dataset).

A single graph, with labels for a subset of nodes.

A single graph, with a set of observed edges.

A single graph.

Output Unit

A single class label or regression value per graph.

A label or value for each target node.

A probability score or binary label for each candidate node pair.

A set of node assignments to clusters or communities.

Key Algorithms

Graph Neural Networks (GNNs), Graph Kernels, Weisfeiler-Lehman subtree kernel.

Graph Convolutional Networks (GCNs), Label Propagation, GraphSAGE.

Heuristic metrics (e.g., Adamic-Adar), Matrix Factorization, GNN-based decoders.

Louvain method, Label Propagation, Girvan-Newman, Infomap.

Use Case Example

Classifying molecular graphs as toxic or non-toxic.

Categorizing users in a social network as 'bot' or 'human'.

Recommending friendships in a social network or products in an e-commerce graph.

Finding functional modules in a protein-protein interaction network.

Requires Graph-Level Labels

Leverages Global Graph Structure

GRAPH CLASSIFICATION

Frequently Asked Questions

Graph classification is a core machine learning task for assigning labels to entire graph structures. These questions address its mechanisms, applications, and relationship to other graph analytics techniques.

Graph classification is a supervised machine learning task where the goal is to predict a categorical label or property for an entire graph data structure based on its global topological features and the attributes of its constituent nodes and edges.

Unlike node classification, which assigns labels to individual nodes, graph classification treats each graph as a single data instance. The task is fundamental in domains where the unit of analysis is a complete network, such as classifying a molecule's toxicity (where the graph represents atomic bonds) or categorizing a social network's community type.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.