Load Graphs into Memory Programmatically
You can use the readGraphByName()
API to
programmatically load graphs into the graph server memory.
The following example loads a SQL Property Graph named
BANK_GRAPH
into memory using the
readGraphByName()
API.
var graph = session.readGraphByName("BANK_GRAPH", GraphSource.PG_SQL)
graph = session.read_graph_by_name("BANK_GRAPH", "pg_sql")
The following example loads a PGQL Property Graph named
BANK_GRAPH
into memory using the
readGraphByName()
API.
var graph = session.readGraphByName("BANK_GRAPH", GraphSource.PG_PGQL)
graph = session.read_graph_by_name("BANK_GRAPH", "pg_pgql")
Once a graph is loaded into memory, you can access the graph in any subsequent notebook paragraphs. For example, you can reference the graph in a PGQL (PGX) paragraph as shown:
%pgql-pgx
SELECT *
FROM GRAPH_TABLE ( bank_graph
MATCH (a IS accounts) -[e IS transfers]-> (b IS accounts)
COLUMNS (e.amount AS amount)
) FETCH FIRST 10 ROWS ONLY