Graph Neural Network (GNN) is a new model that can be used to analyse graphs. Graphs are robust data structures that contain relationships between objects, and GNNs allow you to explore these relationships in new ways. For example, you can use a GNN to identify which people are most likely to recommend a product on social media.

What Is Graph?

A graph is an abstract representation of a network. 

Graphs are used in many fields, including computer science and social science. They are used to model relationships between objects, such as links on the internet, friendships between people on Facebook, or the food chain in an ecosystem. 

In data science, you can use graphs to represent connections between objects.

A graph can be defined as G = (V, E), where V is the set of nodes (vertices) and E is the edges between them. 

Edges can be either directed or undirected, depending on whether directional dependencies exist between vertices. The vertices are often called nodes.

Explore a wide range of Networking Courses at Simplilearn and become a certified networking expert. Transform your career today!

What Are Graph Neural Networks (GNN)?

Graph Neural Networks (GNNs) are the solution to a problem plaguing computer science for years: how can we make computer vision work on graphs?

Graphs have been a central part of computer science since its inception, but it's only recently that we've had the technology to make sense of them. And in many cases, we still need help with the basics.

CNNs are great at image recognition and classification but need to work on graphs. They don't have the capacity for it. 

GNNs come in. They provide an easy way to do node-level, edge-level, and graph-level prediction tasks.

GNNs can do what CNNs failed: give us tools to analyse complicated relationships between objects in a network without creating false connections or missing important information about those relationships.

What Is Graph Convolutional Networks?

Graph convolutional networks (GCNs) are a type of neural network you can use to solve graph-structured data problems.

There are three essential components of a GCN: graph convolution, a linear layer, and a nonlinear activation function. 

The operations are usually done in this order. Together, they make up one network layer. We can combine one or more layers to form a complete GCN.

You can implement a GCN using PyTorch as follows:

import torch

from torch import nn

class GCN(nn.Module):

    def __init__(self, *sizes):


        self.layers = nn.ModuleList([

            nn.Linear(x, y) for x, y in zip(sizes[:-1], sizes[1:])


    def forward(self, vertices, edges):

        # ----- Build the adjacency matrix -----

        # Start with self-connections

        adj = torch.eye(len(vertices))

        # edges contain connected vertices: [vertex_0, vertex_1] 

        adj[edges[:, 0], edges[:, 1]] = 1 

        adj[edges[:, 1], edges[:, 0]] = 1

        # ----- Forward data pass -----

        for layer in self.layers:

            vertices = torch.sigmoid(layer(adj @ vertices))

        return vertices


DeepWalk is a new graph neural network that operates directly on the target graph structure. It uses a randomised path-traversing technique to provide insights into localised structures within networks. It does so by utilising these random paths as sequences that are then used to train a Skip-Gram Language Model.

The Skip-Gram model works by recognising which nodes are most likely to be connected to the input words. These nodes are then used to generate predicted word sequences for those nodes, which you can compare against the actual outputs from the network. This process allows you to create a trained language model that can predict what other words might occur in your input text based solely on its context in the graph structure!

DeepWalk uses this concept to provide insights into localised structures within networks by utilising random paths as sequences and comparing them against the actual output from the network itself.


GraphSAGE is a representation learning technique for dynamic graphs. It uses inductive learning to predict the embedding of a new node without a re-training procedure. It uses aggregator functions to induce new node embeddings based on features and neighbourhoods of the node. Rather than summing and losing track of them, we use a general aggregation function that keeps them separate.

Before we used mean aggregation – we took the message from the neighbours and added them up, then normalised that by the number of neighbours. Now, we can also make a pooling type approach or use deep neural networks like LSTMs.

Applications of GNNs

Graph-structured data is present everywhere. Graphs are a prevalent data structure for storing, analysing, and representing information and finding patterns in data that otherwise might not be discoverable.

Application of GNNs:

  • Node Classification involves determining the labelling of samples by looking at their labels and neighbours' labels. These problems are usually trained semi-supervised, with only a part of the graph labelled.
  • Graph Clustering refers to the clustering of data in the form of graphs. Vertex clustering seeks to cluster nodes into groups of densely connected regions based on either edge weights or edges. The second form of graph clustering treats graphs as objects to be clustered, and these clusters are based on similarity.
  • Graph classification is a crucial technology for image classification, recommendation systems, NLP, and social network analysis.
  • Graph visualisation is an area of mathematics and computer science at the intersection of geometric graph theory and information visualisation. It is concerned with the visual representation of graphs that reveals structures and anomalies that may be present in the data and helps the user to understand the charts.
  • Link prediction is an important task in social networks where it’s essential to infer social interactions between entities or recommend possible friends to users. It has also been used in recommender systems problems and predicting criminal associations.

GNNs in Computer Vision

GNNs are a powerful new tool in computer vision, and their applications are growing daily.

They can be applied to image classification problems, particularly those where there is still much development needed for machines to have the visual intuition of a human.

In one such problem, scene graph generation, the model aims to parse an image into a semantic graph that consists of objects and their semantic relationships. Given an image, scene graph generation models detect and recognise objects and predict semantic relationships between pairs of things.

GNNs in Natural Language Processing

Graph Neural Networks (GNNs) are a powerful tool for solving many NLP problems. 

GNNs have been used to solve tasks like text classification, exploiting semantics in machine translation, user geolocation and relation extraction. Recently, GNNs have also been applied to question answering.

GNNs in Other Domains

Since their invention in the 1960s, GNNs have been applied to various tasks and domains. They have been used to create models for detecting diseases, predicting social trends and patterns, and predicting outcomes of elections.


The traffic prediction problem is a crucial part of any intelligent transportation system. We can address it using STGNNs: we consider the traffic network as a spatial-temporal graph where the nodes are sensors installed on roads, and the distance between pairs of nodes measures the edges. Each node's average traffic speed within a window a dynamic input features.


Graph nodes and edges represent the structure of a molecule. Nodes are atoms, and edges – are chemical bonds.

You can use graphs to analyse the molecular structure of molecules or compounds.


1. What is Graph neural network used for?

Graph Neural Networks are a type of neural network you can use to process graphs directly. In the past, these networks could only process graphs as a whole. 

Graph Neural Networks can then predict the node or edges in graphs. Models built on Graph Neural Networks will have three main focuses: Tasks focusing on nodes, tasks focusing on edges, and tasks focusing on both nodes and edges.

2. How do you graph a neural network?

GNNs are like regular neural networks but better. They're a class of deep learning methods that allow you to do node-level, edge-level, and graph-level prediction tasks easily.

And the best part? You can use them directly on graphs.

3. What is Graph neural network in machine learning?

Graph Neural Networks are Neural Network that directly operates on the graph structure. This paper describes how to use Graph Neural Networks to solve problems in machine learning and computer vision.

4. What are the types of neural graph networks?

The three main types of neural graph networks are:

  • Recurrent Graph Neural Network, 
  • Spatial Convolutional Network
  • Spectral Convolutional Network.

5. What are CNN and GNN?

Convolutional Neural Networks (CNNs) and Graph Neural Networks (GNNs) are two types of deep learning methods that you can use to perform inference on data described by graphs. CNNs are artificial neural networks used in image recognition and processing. At the same time, GNNs are a class of deep learning methods designed to perform inference on data described by graphs.

6. What is the difference between GNN and GCN?

CNNs and GNNs are two types of neural networks. CNNs are specifically designed to operate on structured data, while GNNs are the generalised version of CNNs where the number of nodes can vary, and the nodes are unordered.

It means that CNNs can be applied to structured data such as images or text but not unstructured data such as sound or weather. GNNs can be used for both structured and unstructured data.

Do you wish to accelerate your AL and ML career? Join our AI ML Certification and gain access to 25+ industry relevant projects, career mentorship and more.


Are you looking to learn AI and machine learning?

Then look no further than Simplilearn’s AI ML Courses. The intensive Bootcamp will teach you Deep Learning basics, including Statistics, ML, neural networks, Natural Language Processing and Reinforcement Learning. It’s the perfect course to help you boost your career to greater heights!

Our AI & Machine Learning Courses Duration And Fees

AI & Machine Learning Courses typically range from a few weeks to several months, with fees varying based on program and institution.

Program NameDurationFees
Professional Certificate Program in No Code Machine Learning

Cohort Starts: 19 Jun, 2024

4 Months$ 2,565
Generative AI for Business Transformation

Cohort Starts: 21 Jun, 2024

4 Months$ 3,350
Post Graduate Program in AI and Machine Learning

Cohort Starts: 27 Jun, 2024

11 Months$ 4,300
Applied Generative AI Specialization

Cohort Starts: 9 Jul, 2024

4 Months$ 4,000
AI & Machine Learning Bootcamp

Cohort Starts: 15 Jul, 2024

6 Months$ 10,000
AI and Machine Learning Bootcamp - UT Dallas6 Months$ 8,000
Artificial Intelligence Engineer11 Months$ 1,449

Learn from Industry Experts with free Masterclasses

  • Global Next-Gen AI Engineer Career Roadmap: Salary, Scope, Jobs, Skills

    AI & Machine Learning

    Global Next-Gen AI Engineer Career Roadmap: Salary, Scope, Jobs, Skills

    20th Jun, Thursday9:00 PM IST
  • Kickstart Your Agile Leadership Journey in 2024 with Certified Scrum Mastery

    Project Management

    Kickstart Your Agile Leadership Journey in 2024 with Certified Scrum Mastery

    12th Mar, Tuesday7:00 PM IST
  • Top Risk Management Tools and Techniques for Successful Projects

    Project Management

    Top Risk Management Tools and Techniques for Successful Projects

    14th Dec, Thursday7:00 PM IST