A graph is a data structure containing vertices (or nodes) and edges. The vertices represent objects or entities, while the edges represent the relationship between these vertices.
Using Apache AGE, PostgreSQL can be given the functionalities of a graph database. We will be able to create graph databases and manipulate them in PostgreSQL, and AGE Viewer gives us a visual representation of these graphs.
Apache AGE requires
node (version 14.16.0 recommended) and
npm to run. To download
node, we'll be using Node Version Manager (
Run the following command in your terminal.
sudo apt install curl curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
After the installation is completed, reload the terminal to effect the changes.
node version 14.16.0 using
nvm install 14.16.0
To check your installation, run the following commands to view the versions of
node -v npm -v
Clone AGE Viewer from its repository.
git clone https://github.com/apache/age-viewer.git
Now, install the required node modules and start the viewer. To do that, go into the AGE Viewer folder and run:
npm run setup npm run start
AGE Viewer will run on
localhost:3000 if port 3000 is free.
For this, we'll be using the same data used in my article, Six Degrees of Separation Using Apache AGE.
Connect to your database in AGE Viewer using the following parameters:
- Connect URL:
- Connect Port:
5432(PostgreSQL's port by default)
- Database Name:
- User Name:
- Password: The username and password for the connection, if not set, will be the name and password of the current user.
Run the following code in AGE Viewer.
SELECT * FROM cypher('social_network', $$ MATCH (a:Person)-[e]-(b:Person) RETURN a, e, b $$) AS (a agtype, e agtype, b agtype);
The graph will be displayed.