4.8.2 Compiling and Running a PGX Algorithm
To be able to compile and run a custom PGX algorithm, you must perform several actions:
- Set two configuration parameters in the
conf/pgx.conffile:- Set the
graph_algorithm_languageoption toJAVA. - Set the
java_home_diroption to the path to your Java home (use<system-java-home-dir>to have PGX infer Java home from the system properties).
{ "graph_algorithm_language": "JAVA", "java_home_dir": "<system-java-home-dir>" } - Set the
- Create a session (either implicitly in the shell or explicitly in Java). For example:
cd $PGX_HOME ./bin/opg4j - Compile a PGX Algorithm. For example:
myAlgorithm = session.compileProgram("/path/to/MyAlgorithm.java") - Run the algorithm. For example:
graph = session.readGraphWithProperties("/path/to/config.edge.json") property = graph.createVertexProperty(PropertyType.INTEGER) myAlgorithm.run(graph, property)
Parent topic: Using Custom PGX Graph Algorithms