PGX 20.1.1
Documentation

Graph Config Examples

Example 1

This example illustrates the json configuration for a simple graph configuration object with 1 vertex provider and 1 edge provider:

{
  "name": "simpleGraph",
  "vertex_providers":[{
    "name": "simpleVertexProvider",
    "format": "csv",
    "uris": ["simple.csv"],
    "key_column": 1
  }],
  "edge_providers":[{
    "name": "simpleEdgeProvider",
    "format": "csv",
    "uris": ["simple.csv"],
    "source_vertex_provider":"simpleVertexProvider",
    "destination_vertex_provider":"simpleVertexProvider",
    "key_column": 1,
    "source_column": 2,
    "destination_column": 3
  }]
}

Note that the paths in the uris field are relative paths, 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 provider data in zip:../myzip.zip!/path/data/simple.csv.

Example 2

This example illustrates the json configuration for a graph configuration object with two vertex providers and one edge provider. It also illustrates how to load from different provider formats and how to specify properties.

{
  "name": "typicalGraph",
  "vertex_providers":[{
    "name": "typicalVertexProvider",
    "format": "csv",
    "uris": ["typical.csv"],
    "props": [{
      "name": "prop1",
      "type": "string",
      "column": 2
    }, {
      "name": "prop2",
      "type": "local_date",
      "column": 3
    }],
    "key_column": 1
  },{
    "name": "anotherTypicalVertexProvider",
    "format": "pgb",
    "uris": ["another_typical.pgb"],
    "props": [{
      "name": "rank",
      "type": "float"
    }, {
      "name": "name",
      "type": "string"
    }]
  }],
  "edge_providers":[{
    "name": "typicalEdgeProvider",
    "format": "csv",
    "header": true,
    "uris": ["../typical.csv"],
    "source_vertex_provider": "typicalVertexProvider",
    "destination_vertex_provider": "anotherTypicalVertexProvider",
    "key_column": "EID",
    "source_column": "source",
    "destination_column": "destination",
    "props": [{
      "name": "cost",
      "type": "double"
    }],
    "loading": {
      "create_key_mapping": true
    },
    "error_handling": {
      "on_missing_vertex": "ignore_edge"
    }
  }]
}

Example 3

This example illustrates the json configuration for a complex graph configuration object with 5 vertex providers and 3 edge providers using different formats and combinations. This also illustrates how to load multiple providers from different formats, how to specify properties and other configuration fields.

{
  "name": "complexGraph",
  "vertex_providers":[{
    "name": "Person",
    "format": "csv",
    "header": true,
    "uris": ["person1.csv", "person2.csv", "person3.csv", "person4.csv"],
    "key_column": "VID",
    "props": [{
      "name": "name",
      "type": "string"
    }, {
      "name": "age",
      "type": "integer"
    }]
  }, {
    "name": "Transaction",
    "format": "csv",
    "uris": ["transaction.csv"],
    "key_column": 1,
    "props": [{
      "name": "creationDate",
      "type": "local_date",
      "column": 2
    }],
    "local_date_format": ["dd-MM-yyyy"]
  }, {
    "name": "BankAccount",
    "format": "csv",
    "separator": ",",
    "header": true,
    "key_column": "account",
    "uris": ["bank1.csv", "bank2.csv"],
    "props": [{
      "name": "money",
      "type": "double"
    }]
  }, {
    "name": "House",
    "format": "csv",
    "separator": "|",
    "key_column": 2,
    "uris": ["house1.csv", "house2.csv", "house3.csv"],
    "props": [{
      "name": "sqm",
      "type": "float",
      "column": 1
    }]
  }, {
    "name": "Car",
    "format": "pgb",
    "uris": ["car.pgb"],
    "props": [{
      "name": "numDoors",
      "type": "integer"
    }, {
      "name": "year",
      "type": "integer"
    }]
  }],
  "edge_providers":[{
    "name": "CarOutrunsCar",
    "format": "rdbms",
    "jdbc_url": "jdbc:oracle:thin:@localhost:1521:rdbmsod",
    "username": "scott",
    "password": "tiger",
    "database_table_name": "car_outruns_car",
    "key_column": "EID",
    "source_column" : "SVID",
    "destination_column" : "DVID",
    "source_vertex_provider":"Car",
    "destination_vertex_provider":"Car",
    "props": [{
      "name": "differenceInMillis",
      "type": "long"
    },{
      "name": "sourceTimeInMillis",
      "type": "long"
    },{
      "name": "destinationTimeInMillis",
      "type": "long"
    }],
    "loading": {
      "create_key_mapping": true
    }
  }, {
    "name": "PersonLivesInHouse",
    "format": "csv",
    "uris": ["personLivesInHouse.csv"],
    "header": true,
    "key_column": "EID",
    "source_column": "person",
    "destination_column": "house",
    "source_vertex_provider":"Person",
    "destination_vertex_provider":"House",
    "props": [{
      "name": "movedSince",
      "type": "timestamp",
      "column": "moved_since"
    }]
  }, {
    "name": "BankAccountPaidTransaction",
    "format": "csv",
    "key_column": 1,
    "source_column": 2,
    "destination_column": 3,
    "uris": ["bankAccountPaidTransaction1.csv", "bankAccountPaidTransaction2.csv"],
    "source_vertex_provider":"BankAccount",
    "destination_vertex_provider":"Transaction",
    "error_handling": {
      "on_missing_vertex": "ignore_edge"
    }
  }]
}