4.10.1 Writing a Custom PGX Algorithm
A PGX algorithm is a regular .java file with a single class definition that is
            annotated with @GraphAlgorithm. For example:
               
import oracle.pgx.algorithm.annotations.GraphAlgorithm;
@GraphAlgorithm
public class MyAlgorithm {
    ...
}
A PGX algorithm class must contain exactly one public method which will be used as entry point. The class may contain any number of private methods.
For example:
import oracle.pgx.algorithm.PgxGraph;
import oracle.pgx.algorithm.VertexProperty;
import oracle.pgx.algorithm.annotations.GraphAlgorithm;
import oracle.pgx.algorithm.annotations.Out;
@GraphAlgorithm
public class MyAlgorithm {
    public int myAlgorithm(PgxGraph g, @Out VertexProperty<Integer> distance) {
        System.out.println("My first PGX Algorithm program!");
        return 42;
    }
}
As with normal Java methods, a PGX algorithm method only supports primitive data
            types as return values (an integer in this example). More interesting is the
                @Out annotation, which marks the vertex property
                distance as output parameter. The caller passes output parameters
            by reference. This way, the caller has a reference to the modified property after the
            algorithm terminates.
               
Parent topic: Using Custom PGX Graph Algorithms