Is there an open-source implementation for graph convolution networks for weighted graphs?



Currently, I'm using a Python library, StellarGraph, to implement GCN. And I now have a situation where I have graphs with weighted edges. Unfortunately, StellarGraph doesn't support those graphs

I'm looking for an open-source implementation for graph convolution networks for weighted graphs. I've searched a lot, but mostly they assumed unweighted graphs. Is there an open-source implementation for GCNs for weighted graphs?

port trum

Posted 2019-11-27T06:44:01.577

Reputation: 55

1You can take a look at "Diffusion Convolutional Recurrent Neural Network: Data-Driven Traffic Forecasting" (you can find it on Github). In there you can find an implementation of the diffusion convolution which is applied to a weighted graph, the traffic adjacency matrix. – razvanc92 – 2019-11-28T12:56:37.187



A Comprehensive Survey on Graph Neural Networks (2019) presents a list of ConvGNN's. All of the following accept weighted graphs, and three accept those with edge weights as well:

enter image description here

And below is a series of open source implementations of many of the above:

enter image description here


Posted 2019-11-27T06:44:01.577

Reputation: 423


You can use Pytorch_Geometric library for your projects. Its supports weighted GCNs. It is a rapidly evolving open-source library with easy to use syntax. It is mentioned in the landing page of Pytorch. It is the most starred Pytorch github repo for geometric deep learning. Creating a GCN model which can process graphs with weights is as simple as:

import torch
import torch.nn.functional as F
from torch_geometric.nn import GCNConv

class Net(torch.nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = GCNConv(dataset.num_node_features, 16)
        self.conv2 = GCNConv(16, dataset.num_classes)

    def forward(self, data):

        # data has the following 3 attributes
        x, edge_index, edge_weight = data.x, data.edge_index, data.edge_weight

        x = self.conv1(x, edge_index, edge_weight)
        x = F.relu(x)
        x = F.dropout(x,
        x = self.conv2(x, edge_index, edge_weight)

        return F.log_softmax(x, dim=1)

See this for getting started. Check out its documentation on different variants of GCNs for further details. One of the best thing is that like Pytorch, its documentation are self-sufficient.


Posted 2019-11-27T06:44:01.577

Reputation: 270