PGX 20.2.2
Documentation

Graph Configuration Examples

Example 1

This example illustrates the json configuration for a graph in csv format whose vertices and edges data are stored in data/vertices.csv and data/vertices.csv respectively.

{
  "format": "csv",
  "vertex_uris": ["data/vertices.csv"],
  "edge_uris": ["data/edges.csv"],
}

Example 2

This example illustrates the json configuration for a graph in adj_list format whose data is stored in data/my-graph.adj:

{
  "format": "adj_list",
  "uri": "data/my-graph.adj"
}

Note that the path in the uri field is a relative path, resolved relative to the parent directory of its configuration file. So if the above JSON is located in a file zip:../myzip.zip!/path/my-config.json, then PGX will look for the graph data in zip:../myzip.zip!/path/data/my-graph.adj.

Example 3

This example illustrates the json configuration for a graph in two_tables format stored in HDFS, containing one edge property of type double named cost:

{
  "format": "two_tables",
  "uri": "hdfs:/graphs/my-graph.adj",
  "vertex_uris": ["hdfs:/graphs/vertices.csv"],
  "edge_uris": ["hdfs:/graphs/edges.csv"],
  "edge_props": [{
    "name": "cost",
    "type": "double"
  }]
}

Example 4

This example illustrates the json configuration for a graph in edge_list format to be loaded from the classpath, having a non-default separator:

{
  "format": "edge_list",
  "uri": "classpath:/graphs/my-graph.edge",
  "separator": "|"
}

Example 5

This example illustrates the json configuration for a graph in graphml format stored on a web server to be retrieved over HTTP with two vertex properties (the first of type string and the second of type int) and one edge property (of type double) with 1.0 specified as default value. Vertices are identified using strings:

{
  "format": "graphml",
  "uri": "https://my-server.com/graphs/my-graph.graphml",
  "vertex_id_type": "string",
  "vertex_props": [{
    "name": "my-vertex-property",
    "type": "string"
  }, {
    "name": "my-second-vertex-property",
    "type": "integer"
  }],
  "edge_props": [{
    "name": "my-edge-property",
    "type": "double",
    "default": 1.0
  }]
}

Note that the configuration file must contain definitions for vertex_props and edge_props if present, even though graphml format allows these to be specified in the data file.

Example 6

This example illustrates the json configuration for a graph in Property Graph format named my-graph to be loaded from an Oracle NoSQL database:

{
  "format": "pg",
  "db_engine": "nosql",
  "hosts": [
    "my-host1:5000",
    "my-host2:5000",
    "my-host3:5000"
  ],
  "store_name": "my-store",
  "name": "my-graph",
  "vertex_props": [{
    "name": "prop",
    "type": "float"
  }],
  "edge_props": [{
    "name": "name",
    "type": "string"
  }, {
    "name": "cost",
    "type": "double"
  }]
}

Example 7

This example illustrates the json configuration for a graph in flat_file format stored on a local file with two vertex properties (the first of type string and the second of type int) and one edge property (of type float).

{
  "vertex_uris": [ "example.opv" ],
  "edge_uris": [ "example.ope" ],
  "format": "flat_file",
  "separator": ",",
  "node_props":[
      {
        "name":"examplestring",
        "type":"string"
      },
      {
        "name":"exampleint",
        "type":"integer"
      }
  ],
  "edge_props":[
      {
        "name":"examplefloat",
        "type":"float"
      }
  ]
}

Note that, although the flat file format already specifies the property names in the data, the graph configuration still needs to contain the definition for vertex_props and edge_props, if any vertex or edge properties are present in the graph. Additionally, the graph configuration must contain two types of URI list: one list for the files containing the vertices, e.g., [example.opv, example2.opv] and one one list for the files containing the edges, e.g., [example.ope, example2.ope].

Example 8

This example illustrates the json configuration for a graph in flat_file format stored on multiple local files with two vertex properties (the first of type string and the second of type int) and one edge property (of type float).

{
  "vertex_uris": [ "example.opv", "example2.opv" ],
  "edge_uris": [ "example.ope", "example2.ope" ],
  "format": "flat_file",
  "separator": ",",
  "node_props":[
      {
        "name":"examplestring",
        "type":"string"
      },
      {
        "name":"exampleint",
        "type":"integer"
      }
  ],
  "edge_props":[
      {
        "name":"examplefloat",
        "type":"float"
      }
  ]
}

Note that, although the flat file format already specifies the property names in the data, the graph configuration still needs to contain the definition for vertex_props and edge_props, if any vertex or edge properties are present in the graph. Additionally, the graph configuration must contain two types of URI list: one list for the files containing the vertices, e.g., [example.opv, example2.opv] and one one list for the files containing the edges, e.g., [example.ope, example2.ope].

Example 9

This example illustrates the json configuration for a graph in two_tables format to be loaded from an Oracle Rdbms database:

 {
  "jdbc_url": "jdbc:oracle:thin:@mydatabaseserver:1521/dbName",
  "format": "two_tables",
  "datastore": "rdbms",
  "username": "dbUser",
  "password": "dbPassword",
  "vertices_table_name": "vertices",
  "edges_table_name": "edges",
  "vertex_props": [{
    "name": "NP1",
    "type": "string"
  },{
    "name": "NP2",
    "type": "timestamp"
  },{
    "name": "NP3",
    "type": "double"
  }],
  "edge_props": [{
    "name": "EP1",
    "type": "string"
  },{
    "name": "EP2",
    "type": "timestamp"
  },{
    "name": "EP3",
    "type": "float"
  }]
}

Example 10

This example illustrates the json configuration for a graph in two_tables format to be loaded from text files:

 {
  "format": "two_tables",
  "datastore": "file",
  "vertex_uris": [ "example.nodes", "example2.nodes" ],
  "edge_uris": [ "example.edges", "example2.edges" ],
  "separator": ",",
  "vertex_props": [{
    "name": "NP1",
    "type": "string"
  },{
    "name": "NP2",
    "type": "timestamp"
  },{
    "name": "NP3",
    "type": "double"
  }],
  "edge_props": [{
    "name": "EP1",
    "type": "string"
  },{
    "name": "EP2",
    "type": "timestamp"
  },{
    "name": "EP3",
    "type": "float"
  }]
}

Example 11

The same graph as in example 5, this time described in Java Properties format:

format = pg
db_engine = nosql
hosts.1 = my-host1:5000
hosts.2 = my-host2:5000
hosts.3 = my-host3:5000
store_name = my-store
name = my-graph
node_props.1.name = prop
node_props.1.type = float
edge_props.1.name = name
edge_props.1.type = string
edge_props.2.name = cost
edge_props.2.type = double