15.2.1 Loading a Graph

The following describes the steps for loading a graph:
  1. Create a Session and an Analyst.
    cd /opt/oracle/graph/
    ./bin/opg4j
    // starting the shell will create an implicit session and analyst
    opg4j> import oracle.pgx.config.mllib.ActivationFunction
    opg4j> import oracle.pgx.config.mllib.WeightInitScheme
    opg4j> PgxSession session = Pgx.createSession("my-session")
    opg4j> Analyst analyst = session.createAnalyst()
    import oracle.pgx.api.*;
    import oracle.pgx.api.mllib.SupervisedGraphWiseModel;
    import oracle.pgx.api.filter.VertexFilter;
    import oracle.pgx.api.frames.*;
    import oracle.pgx.config.mllib.ActivationFunction;
    import oracle.pgx.config.mllib.GraphWiseConvLayerConfig;
    import oracle.pgx.config.mllib.GraphWisePredictionLayerConfig;
    import oracle.pgx.config.mllib.SupervisedGraphWiseModelConfig;
    import oracle.pgx.config.mllib.WeightInitScheme;
    PgxSession session = Pgx.createSession("my-session");
    Analyst analyst = session.createAnalyst();
    session = pypgx.get_session(session_name="my-session")
    analyst = session.create_analyst()
  2. Load the graph.
    opg4j> var fullGraph = session.readGraphWithProperties("<path>/<cora_full_graph.json>")
    opg4j> var filter = VertexFilter.fromPgqlResultSet(session.queryPgql("SELECT v FROM cora MATCH (v) WHERE ID(v) % 4 > 0"), "v")
    opg4j> var trainGraph = fullGraph.filter(filter)
    opg4j> var testVertices = fullGraph.getVertices().
                     stream().
                     filter(v -> !trainGraph.hasVertex(v.getId())).
                     collect(Collectors.toList())
    PgxGraph fullGraph = session.readGraphWithProperties("<path>/<cora_full_graph.json>");
    VertexFilterfilter = VertexFilter.fromPgqlResultSet(session.queryPgql("SELECT v FROM cora MATCH (v) WHERE ID(v) % 4 > 0"),"v");PgxGraphtrainGraph=fullGraph.filter(filter);
    PgxGraph trainGraph = fullGraph.filter(filter);
    List<PgxVertex> testVertices = fullGraph.getVertices()
        .stream()
        .filter(v->!trainGraph.hasVertex(v.getId()))
        .collect(Collectors.toList());
    from pypgx.api.filters import VertexFilter
    full_graph = session.read_graph_with_properties("<path>/<cora_full_graph.json>")
    vertex_filter = VertexFilter.from_pgql_result_set(session.query_pgql("SELECT v FROM cora MATCH (v) WHERE ID(v) % 4 > 0"),"v")
    train_graph = full_graph.filter(vertex_filter)
    test_vertices = []
    train_vertices = train_graph.get_vertices()
    for v in full_graph.get_vertices():
        if(not train_vertices.contains(v)):
            test_vertices.append(v)