Graph functions

graph.names()

Returns a list containing the names of all graphs on the current composite database. It is only supported on composite databases.

Example 1. graph.names()
Setup
CREATE DATABASE dba;
CREATE DATABASE dbb;
CREATE DATABASE dbc;
CREATE COMPOSITE DATABASE composite;
CREATE ALIAS composite.first FOR DATABASE dba;
CREATE ALIAS composite.second FOR DATABASE dbb;
CREATE ALIAS composite.third FOR DATABASE dbc;
Query
RETURN graph.names() AS name

The names of all graphs on the current composite database are returned.

Table 1. Result
name

"composite.first"

"composite.second"

"composite.third"

Rows: 3

graph.propertiesByName()

Returns a map containing the properties associated with the given graph. The properties are set on the aliasthat adds the graph as a constituent of a composite database. It is only supported on composite databases.

Example 2. graph.propertiesByName()
Setup
CREATE DATABASE dba;
CREATE DATABASE dbb;
CREATE DATABASE dbc;
CREATE COMPOSITE DATABASE composite;
CREATE ALIAS composite.first FOR DATABASE dba
  PROPERTIES {number: 1, tags: ['A', 'B']};
CREATE ALIAS composite.second FOR DATABASE dbb
  PROPERTIES {number: 0, tags: ['A']};
CREATE ALIAS composite.third FOR DATABASE dbc
  PROPERTIES {number: 2, tags: ['B', 'C']};
Query
UNWIND graph.names() AS name
RETURN name, graph.propertiesByName(name) AS props

Properties for all graphs on the current composite database are returned.

Table 2. Result
name props

"composite.first"

{number: 1, tags: ["A", "B"]}

"composite.second"

{number: 0, tags: ["A"]}

"composite.third"

{number: 2, tags: ["B", "C"]}

Rows: 3

Query
UNWIND graph.names() AS name
WITH name, graph.propertiesByName(name) AS props
WHERE "A" IN props.tags
CALL {
  USE graph.byName(name)
  MATCH (n)
  RETURN n
}
RETURN n

Returns all nodes from a subset of graphs that have a tags property containing "A".

graph.byName()

Resolves a constituent graph by name. It is only supported in the USE clause, on composite databases.

Example 3. graph.byName()
Query
UNWIND graph.names() AS graphName
CALL {
  USE graph.byName(graphName)
  MATCH (n)
  RETURN n
}
RETURN n

Returns all nodes from all graphs on the current composite database.

graph.byElementId()

The graph.byElementId() function is used in the USE clause to resolve a constituent graph to which a given element id belongs. If the constituent database is not a standard database in the DBMS, an error will be thrown.

Example 4. graph.byElementId()

In this example, it is assumed that the DBMS contains a composite database constituent, which contains the element id 4:c0a65d96-4993-4b0c-b036-e7ebd9174905:0.

Query
USE graph.byElementId("4:c0a65d96-4993-4b0c-b036-e7ebd9174905:0")
MATCH (n) RETURN n