TigerGraph Microblog: Installing Graph Algorithms in Python

Using pyTigerGraph’s Graph Data Science Functions with the COVID-19 Patient Starter Kit

Shreya Chaudhary
4 min readJun 5, 2022
Image from Pixabay

Introduction

Objective

In this blog, you will learn how to install graph algorithms to your TigerGraph solution. Specifically, the blog will use the example of installing PageRank with the COVID-19 starter kit.

Tools Used

Prerequisite: Create the COVID-19 Starter Kit on TigerGraph Cloud

Before creating graph algorithms, start by loading the COVID-19 starter kit. Create an account on https://tgcloud.io/, navigate to the “My Solutions” tab, then press the blue “Create Solution” button.

On the first, select the COVID-19 starter kit.

Don’t change anything on the second page; this will simply set up a free TigerGraph solution. On the third page, customise your solution.

Finally, verify that everything looks good on the final page then press submit. Wait till the status of your solution is green (Ready), then open GraphStudio by pressing the “Applications” button and selecting GraphStudio from the dropdown.

In GraphStudio, navigate to the COVID-19 graph by clicking “Global View” then selecting “MyGraph” from the dropdown.

Finally, load the data by navigating to the “Load Data” tab and then pressing the play button in the top left corner.

Once all of your data is loaded, the solution is ready and you can start running algorithms using pyTigerGraph.

Installing and Running PageRank with pyTigerGraph

To start, import pyTigerGraph with GDS to access the Graph Data Science functionalities.

pip install pyTigerGraph[gds]

Next, connect to the TigerGraph solution you just created.

import pyTigerGraph as tgconn = tg.TigerGraphConnection(host = "https://SUBDOMAIN.i.tgcloud.io/", graphname = "MyGraph", username = "tigergraph", password = "PASSWORD")
conn.apiToken = conn.getToken(conn.createSecret())

Note: Modify SUBDOMAIN and PASSWORD to the subdomain and password set while creating the solution. MyGraph and tigergraph are the default graph name and username, respectively; modify them if needed.

You can create a new featurizer.

f = conn.gds.featurizer()

The featurizer has a few functions, including listing and installing algorithms. You can view the list of algorithms with the following command:

f.listAlgorithms()

In this example, we will install the unweighted Pagerank algorithm. You can do so with the installAlgorithm command, passing a parameter of tg_pagerank.

f.installAlgorithm('tg_pagerank')

This may take several minutes to install. Once it is ready, you can run it using conn.runInstalledQuery. While there are several parameters for Pagerank, I just passed the default parameters, vertex and edge type.

conn.runInstalledQuery("tg_pagerank", params = {"v_type": "Patient", "e_type": "INFECTED_BY"})

Perfect! With that, you can now leverage TigerGraph graph algorithms with your solution!

Resources and Next Steps

Congrats! You can now leverage the power of graph algorithms in your solution! Check out the interactive Colab version of this blog:

For more in-depth tutorials and samples, check out the GitHub repository.

Finally, this blog is merely scratching the surface of the awesome graph data science capabilities of pyTigerGraph. To learn about more features, like loading and splitting data and more, check out the pyTigerGraph GDS documentation!

--

--