Dropping graphs

To free up memory, we can drop unused graphs. In order to do so, the gds.graph.drop procedure comes in handy.

Syntax

Drop a graph from the catalog:
CALL gds.graph.drop(
  graphName: String,
  failIfMissing: Boolean,
  dbName: String,
  username: String
) YIELD
  graphName: String,
  database: String,
  databaseLocation: String,
  configuration: Map,
  nodeCount: Integer,
  relationshipCount: Integer,
  schema: Map,
  schemaWithOrientation: Map,
  density: Float,
  creationTime: Datetime,
  modificationTime: Datetime,
  sizeInBytes: Integer,
  memoryUsage: String
Table 1. Parameters
Name Type Optional Description

graphName

String

no

The name under which the graph is stored in the catalog.

failIfMissing

Boolean

true

By default, the library will raise an error when trying to remove a non-existing graph. When set to false, the procedure returns an empty result.

dbName

String

active database name

Then name of the database that was used to project the graph. When empty, the current database is used.

username

String

active user

The name of the user who projected the graph. Can only be used by GDS administrator.

Table 2. Results
Name Type Description

graphName

String

Name of the removed graph.

database

String

Name of the database in which the graph has been projected.

databaseLocation

String

Location of the database from which the graph has been projected. Can be one of local, remote or none.

configuration

Map

The configuration used to project the graph in memory.

nodeCount

Integer

Number of nodes in the graph.

relationshipCount

Integer

Number of relationships in the graph.

schema

Map

Node labels, Relationship types and properties contained in the in-memory graph.

schemaWithOrientation

Map

Node labels, relationship types, relationship orientation and properties contained in the projected graph.

density

Float

Density of the graph.

creationTime

Datetime

Time when the graph was projected.

modificationTime

Datetime

Time when the graph was last modified.

sizeInBytes

Integer

Number of bytes used in the Java heap to store the graph.

memoryUsage

String

Human readable description of sizeInBytes.

Examples

All the examples below should be run in an empty database.

In this section we are going to demonstrate the usage of gds.graph.drop. All the graph names used in these examples are fictive and should be replaced with real values.

Basic usage

Remove a graph from the catalog:
CALL gds.graph.drop('my-store-graph') YIELD graphName;

If we run the example above twice, the second time it will raise an error. If we want the procedure to fail silently on non-existing graphs, we can set a boolean flag as the second parameter to false. This will yield an empty result for non-existing graphs.

Try removing a graph from the catalog:
CALL gds.graph.drop('my-fictive-graph', false) YIELD graphName;

Multi-database support

If we want to drop a graph projected on another database, we can set the database name as the third parameter.

Try removing a graph from the catalog:
CALL gds.graph.drop('my-fictive-graph', true, 'my-other-db') YIELD graphName;

Multi-user support

If we are a GDS administrator and want to drop a graph that belongs to another user we can set the username as the fourth parameter to the procedure. This is useful if there are multiple users with graphs of the same name.

Remove a graph from a specific user’s graph catalog:
CALL gds.graph.drop('my-fictive-graph', true, '', 'another-user') YIELD graphName;

See Administration for more details on this.