StellarGraph is a Python library for machine learning on graph-structured (or equivalently, network-structured) data.

Graph-structured data represent entities, e.g., people, as nodes (or equivalently, vertices), and relationships between entities, e.g., friendship, as links (or equivalently, edges). Nodes and links may have associated attributes such as age, income, time when a friendship was established, etc. StellarGraph supports analysis of both homogeneous networks (with nodes and links of one type) and heterogeneous networks (with more than one type of nodes and/or links).

The StellarGraph library implements several state-of-the-art algorithms for applying machine learning methods to discover patterns and answer questions using graph-structured data.

The StellarGraph library can be used to solve tasks using graph-structured data, such as: - Representation learning for nodes and edges, to be used for visualisation and various downstream machine learning tasks; - Classification and attribute inference of nodes or edges; - Link prediction; - Interpretation of node classification through calculated importances of edges and neighbour nodes for selected target nodes.

We provide Examples of using StellarGraph to solve such tasks using several real-world datasets.

Getting Started

To get started with StellarGraph you’ll need data structured as homogeneous or heterogeneous graph, including attributes for the entities represented as graph nodes. NetworkX is used to represent the graph and Pandas, Scikit-Learn, and/or Numpy can be used to are used to store node attributes.

Detailed and narrated examples of various machine learning workflows on network data, supported by StellarGraph, from data ingestion into graph structure to inference, are given in the demos directory of this repository.


Main requirements (all requirements are in requirements.txt)


StellarGraph is a Python 3 library and requires Python version 3.6 to function (note that the library uses Keras with the Tensorflow backend, and thus does not currently work in python 3.7). The required Python version can be downloaded and installed from Alternatively, use the Anaconda Python environment, available from

The StellarGraph library can be installed in one of two ways, described next.

Install StellarGraph using pip:

To install StellarGraph library from PyPi using pip, execute the following command:

pip install stellargraph

Some of the examples require installing additional dependencies as well as stellargraph. To install these dependencies using pip, execute the following command:

pip install stellargraph[demos]

Install StellarGraph from Github source:

Install a git client, for example install the XCode git client by typing:

git --install

First, clone the StellarGraph repository using git:

git clone

Then, cd to the StellarGraph folder, and install the libraray by executing the following commands:

cd stellargraph
pip install -r requirements.txt
pip install .

Other requirements are the NetworkX library (to create and modify graphs and networks), numpy (to manipulate numeric arrays), pandas (to manipulate tabular data), and gensim (to use the Word2Vec model), scikit-learn (to prepare datasets for machine learning), and matplotlib (for plotting).


Getting the datasets

The StellarGraph examples require datasets to work. They are not supplied with stellargraph, and need to be downloaded separately.

CORA dataset

This dataset can be downloaded from

Download and unzip the cora.tgz file to a location on your computer and pass this location as a command line argument to the example scripts, as detailed below.

Running the GraphSAGE Cora Node Classification Example

  • Install the stellargraph Python library, explained in the previous section.

  • If you haven’t already done so, clone the StellarGraph repository using git:

    git clone
  • Download and decompress the CORA dataset (see Getting the datasets above).

  • Change to the Cora node classification directory under demos:

    cd /path/to/stellargraph/demos/node-classification-graphsage
  • Run the example script and specify the location of the downloaded CORA dataset with the following command:

    python -l <path_to_cora_dataset>
  • Additional arguments can be specified that change the GraphSAGE model and training parameters, a description of these arguments is displayed using the help option to the script:

    python --help

Running Other Examples

There are several other examples in the demos directory. Read the in the demos directory to find out more.