13.1.4 Creating a JSON Configuration to Load a Graph

In order to load a graph into the graph server (PGX), you can create a graph configuration file, which contains metadata about the graph to be loaded. See Graph Configuration Options for more details on graph configuration options.

The following shows a sample graph configuration file:
{
  "name": "bank_graph_analytics",
  "vertex_providers":[
        {
            "name":"Accounts",
            "format":"rdbms",
            "database_table_name":"BANK_NODES",
            "key_column":"ID",
            "key_type": "integer"
        }
    ],
    "edge_providers":[
        {
            "name":"Transfers",
            "format":"rdbms",
            "database_table_name":"BANK_EDGES_AMT",
            "key_column":"ID",
            "source_column":"SRC_ID",
            "destination_column":"DEST_ID",
            "source_vertex_provider":"Accounts",
            "destination_vertex_provider":"Accounts",
            "props":[
                {
                        "name":"AMOUNT",
                        "type":"float"
                }
            ]
        }
    ]
}

You can now read the graph into the graph server (PGX) using the PgxSession API method as shown:

Loading a Graph Using JShell
opg4j> session.readGraphWithProperties("bank_graph_analytics.json")
Loading a Graph Using Java
PgxGraph g = session.readGraphWithProperties("bank_graph_analytics.json")
Loading a Graph Using Python
g = session.read_graph_with_properties("bank_graph_analytics.json")

You can also create a graph configuration file using keystore details. See the example in Loading Graph Configuration Using Keystore for more information.

See API for Loading Graphs into Memory for more information on PgxSession API methods for reading graphs into memory.