Connection Driver Reference
JDBC Manual
OCGraph Java Library
the ocgraph {{java}} class in the {{ocient}} system implements a set of graph operations (similar to {{spark}} graphx) directly on tables using jdbc sql the overall structure of a graph comprises at least two database tables one for vertices (nodes) and one for edges (directed links) the ocgraph library runs graph algorithms and transformations by executing sql over these tables getting started to use the ocgraph library of methods, you must have access to an installed ocient system and the jdbc driver for details, see docid apnndn tjqmjdd5oqdvd use jdbc for connectivity and the ocgraph class for graph apis the java library depends on a valid java sql statement class to connect to the ocient system the class builds and executes sql using that statement and does not manage connections itself import the ocgraph class specify the com ocient jdbc graph ocgraph class in the import declaration import java sql connection; import java sql drivermanager; import java sql statement; import com ocient jdbc graph ocgraph; data model requirements database tables that use the ocgraph library must adhere to a graphx table structure in addition to the listed requirements, tables can include other columns true 200,200,201 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type subgraph and filtering use a subgraph or various filters to restrict a graph to relevant vertices and edges these methods create filtered copies or masked intersections, preserving schema and optional indexes for performance subgraph creates filtered vertex and edge tables using vertex and triplet predicates, retaining only edges with endpoints that remain after vertex filtering the method creates the requested indexes and performs best effort cleanup in the event of failure syntax subgraph( inputschema, inputverticestable, inputedgestable, resultschema, resultverticestable, resultedgestable, vertexfilter, edgefilter, \[ resultverticesindexes \[ , ] ], \[ resultedgesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example create an active customer subgraph that includes only purchases exceeding $50 where the source and destination share a region ocgraph subgraph( "sales", "customers", "purchases", "sales", "customers active", "purchases active", "status = 'active' and score > 0", "b amount > 50 and a region = c region", new arraylist<>(list of("id","region")), new arraylist<>(list of("srcid","destid")), stmt ); filtervertices creates a filtered subgraph by selecting vertices that match a predicate while retaining only edges with endpoints that are in the filtered vertex set syntax filtervertices( inputschema, inputverticestable, inputedgestable, resultschema, resultverticestable, resultedgestable, vertexfilter, \[ resultverticesindexes \[ , ] ], \[ resultedgesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example filter us customers and retain edges with endpoints that remain in the filtered vertex set ocgraph filtervertices( "sales", "customers", "purchases", "sales", "customers us", "purchases us", "country = 'us'", new arraylist<>(list of("id")), new arraylist<>(list of("srcid","destid")), stmt ); filteredges creates a filtered edges table by selecting edges that match a predicate syntax filteredges( inputschema, inputedgestable, resultschema, resultedgestable, edgefilter, \[ resultedgesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example this example demonstrates how to create a filtered edges table from an existing purchases edge set by keeping only edges that meet a business rule ( weight > 0 5 and active ) then, the filteredges method indexes the result on the srcid and destid columns for faster lookups ocgraph filteredges( "sales", "purchases", "sales", "purchases filtered", "weight > 0 5 and type = 'active'", new arraylist<>(list of("srcid","destid")), stmt ); mask creates a masked subgraph by intersecting two graphs vertices intersect if the vertex identifier is present in both graphs edges intersect when the srcid and destid values are present in both graphs the method copies rows that intersect from the graph defined by the arguments inputverticestable and inputedgestable , including any attributes you can optionally create indexes on the result subgraph tables syntax mask( inputschema, inputverticestable, inputedgestable, otherschema, otherverticestable, otheredgestable, resultschema, resultverticestable, resultedgestable, \[ resultverticesindexes \[ , ] ], \[ resultedgesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example create a masked subgraph by intersecting two graphs the example copies vertices and edges that are present in both graphs, along with the remaining endpoints ocgraph mask( "sales", "customers", "purchases", "ref", "customers ref", "purchases ref", "sales", "customers masked", "purchases masked", new arraylist<>(list of("id")), new arraylist<>(list of("srcid","destid")), stmt ); transformations construct new vertex or edge tables by computing derived columns, reversing direction, or aggregating duplicates these methods do not change the original inputs instead, the methods materialize new results mapvertices creates a new vertices table with the identifier id and computed columns use the resultcolumnexpressions argument to calculate additional columns this method can also add indexes before inserting data syntax mapvertices( inputschema, inputverticestable, resultschema, resultverticestable, resultcolumnexpressions \[ , ], \[ resultverticesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example create vertices by adding derived columns, name upper and is vip , and generate indexes for the id and name upper columns ocgraph mapvertices( "sales", "customers", "sales", "customers enriched", new arraylist<>(list of( "upper(name) as name upper", "case when score > 1000 then true else false end as is vip" )), new arraylist<>(list of("id","name upper")), stmt ); mapedges creates a new edges table with srcid , destid , and computed columns expressions should refer to input edge columns by their original names, and each computed expression should include an as alias keyword syntax mapedges( inputschema, inputedgestable, resultschema, resultedgestable, \[ resultcolumnexpressions \[ , ] ], \[ resultedgesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example create a new edges table with two columns, discounted amount and big txn , and generate indexes for the srcid and destid columns ocgraph mapedges( "sales", "purchases", "sales", "purchases enriched", new arraylist<>(list of( "amount 0 9 as discounted amount", "case when amount > 100 then 1 else 0 end as big txn" )), new arraylist<>(list of("srcid","destid")), stmt ); maptriplets creates a new edges table with computed columns that reference a triplet made of a (source vertex), b (edge), and c (destination vertex) the output automatically includes b srcid and b destid columns syntax maptriplets( inputschema, inputverticestable, inputedgestable, resultschema, resultedgestable, \[ resultcolumnexpressions \[ , ] ], \[ resultedgesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example create a new triplet table from the vertices and edges tables with the amount and same country columns, and generate indexes for the src and destid columns ocgraph maptriplets( "sales", "customers", "purchases", "sales", "purchases triplets", new arraylist<>(list of( "b amount as amount", "case when a country = c country then 1 else 0 end as same country" )), new arraylist<>(list of("srcid","destid")), stmt ); reverseedges creates a new edges table with the srcid and destid columns reversed, preserving other columns use this method to traverse a graph in the opposite direction syntax reverseedges( inputschema, inputedgestable, resultschema, resultedgestable, \[ resultedgesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example transform edge direction by reversing the srcid and destid columns the example also creates indexes for these columns ocgraph reverseedges( "sales", "purchases", "sales", "purchases reversed", new arraylist<>(list of("srcid","destid")), stmt ); groupedges groups duplicate rows of the srcid and destid columns, producing one row for each unique pair of values in a new edges table this method performs aggregations based on one or more sql expressions syntax groupedges( inputschema, inputedgestable, resultschema, resultedgestable, resultcolumnexpressions \[ , ], \[ resultedgesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example create a new edge table that includes sql aggregations for counting unique transactions txn count and total sums total amount also, this method generates indexes for the src and destid columns ocgraph groupedges( "sales", "purchases", "sales", "purchases grouped", new arraylist<>(list of( "count( ) as txn count", "sum(amount) as total amount" )), new arraylist<>(list of("srcid","destid")), stmt ); triplets produce triplet representations that are made of a (source vertex), b (edge), and c (destination vertex), either as a logical view or a materialized table for downstream queries createtripletsview creates a view that combines the edge table with the source and destination vertex attributes this view is useful for analyzing relationships without having to repeatedly join tables the view includes these columns all original edge columns (including the srcid and destid columns) all source vertex columns except id source vertex column names have the src prefix all destination vertex columns except id destination vertex column names have the dest prefix use the docid\ hoxig9l4m5f2kisrve3ge method if you want to create a materialized table with indexes instead of a view syntax createtripletsview( inputschema, inputverticestable, inputedgestable, resultschema, resulttripletsview, stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example create a triplets view to inspect edges with joined source and destination vertex attributes ocgraph createtripletsview( "sales", "customers", "purchases", "sales", "triplets v", stmt ); createtripletstable creates a materialized table that combines the edge table with the source and destination vertex attributes this table is useful for analyzing relationships without having to repeatedly join tables the created table includes these columns all original edge columns (including the srcid and destid columns) all source vertex columns except id source vertex column names have the src prefix all destination vertex columns except id destination vertex column names have the dest prefix use the docid\ hoxig9l4m5f2kisrve3ge method if you want to create a view instead of a new table syntax createtripletstable( inputschema, inputverticestable, inputedgestable, resultschema, resulttripletstable, \[ resulttripletsindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example create a new table for triplets generate indexes for the src id and dest id columns ocgraph createtripletstable( "sales", "customers", "purchases", "sales", "triplets t", new arraylist<>(list of("src id","dest id")), stmt ); degrees compute degree metrics for each vertex from the edges table these methods produce small vertex tables suitable for joins and analytics indegrees computes how many edges point to each vertex in an edge table by counting how many times each unique destid value appears the result table has two columns id (the destination vertex) and in degree (the count) syntax indegrees( inputschema, inputedgestable, resultschema, resultverticestable, \[ resultverticesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example compute in degrees per vertex and generate an index on the id column ocgraph indegrees( "sales", "purchases", "sales", "customers in degree", new arraylist<>(list of("id")), stmt ); outdegrees computes how many edges originate from each vertex in an edge table by counting how many times each unique srcid value appears the result table has two columns id (the source vertex) and out degree (the count) syntax outdegrees( inputschema, inputedgestable, resultschema, resultverticestable, \[ resultverticesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example compute the out degree count for each vertex and generate an index on the id column ocgraph outdegrees( "sales", "purchases", "sales", "customers out degree", new arraylist<>(list of("id")), stmt ); degrees computes the total degrees (in degrees and out degrees) for each vertex in an edge table by counting how many times each unique srcid and destid value appears the result table has two columns id (the destination or source vertex) and degree (the count) syntax degrees( inputschema, inputedgestable, resultschema, resultverticestable, \[ resultverticesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example compute total degrees for each vertex and generate an index on the id column ocgraph degrees( "sales", "purchases", "sales", "customers degree", new arraylist<>(list of("id")), stmt ); vertex extraction and joins build vertex sets from edges and combine vertex attributes across tables these methods are useful for shaping vertex properties and consolidating features fromedges builds a vertices table from an edges table by extracting the unique source and destination identifiers this method can optionally compute additional columns using sql expressions by referencing the unique identifier as ids id the created table always contains the id column with one additional column per expression syntax fromedges( inputschema, inputedgestable, resultschema, resultverticestable, \[ resultcolumnexpressions \[ , ] ], \[ resultverticesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example create a vertices table from edge endpoints and add a bucket column that assigns each vertex to one of 10 buckets generate an index for the id and bucket columns ocgraph fromedges( "sales", "purchases", "sales", "customers from edges", new arraylist<>(list of( "ids id % 10 as bucket" )), new arraylist<>(list of("id","bucket")), stmt ); joinvertices merges two vertices tables by retaining every row from a primary table ( inputverticestable ) and selectively updating rows that also appear in the modification table ( modificationverticestable ) the merged table includes all vertices from the primary table that do not appear in the modification table for vertices that appear in both tables, the method must include a list of expressions ( resultattributeexpressions ) in the same column order for every non identifier column in the merged result table these sql expressions can add computations to columns or simply add aliases if no changes are needed each expression can reference columns from the primary table (using alias a ) or from the modification table (using alias b ) syntax joinvertices( inputschema, inputverticestable, modificationschema, modificationverticestable, resultschema, resultverticestable, resultattributeexpressions \[ , ], \[ resultverticesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example merge vertex attributes and generate indexes for the id and status columns this example includes two sql expressions to update the status and score columns based on the modification vertex table using the coalesce sql reference function ocgraph joinvertices( "sales", "customers", "sales", "customers updates", "sales", "customers merged", new arraylist<>(list of( "coalesce(b new status, a status) as status", "coalesce(b score delta + a score, a score) as score" )), new arraylist<>(list of("id","status")), stmt ); innerjoinvertices performs an inner join on two vertex tables using an equality comparison a id = b id the result table automatically includes the id column from the first table the method must include a list of sql expressions ( resultattributeexpressions ) in the same column order for every non identifier column in the merged result table these sql expressions can add computations to columns, or simply add aliases if no changes are needed each expression can reference columns from the primary table using the alias a or from the modification table using the alias b syntax innerjoinvertices( inputschema, inputverticestable, otherschema, otherverticestable, resultschema, resultverticestable, resultattributeexpressions \[ , ], \[ resultverticesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example create an inner join between two vertex tables and generate an index on the id column ocgraph innerjoinvertices( "sales", "customers", "sales", "profiles", "sales", "customers joined", new arraylist<>(list of( "a id as id", "a status as status", "b tier as tier" )), new arraylist<>(list of("id")), stmt ); outerjoinvertices performs a left outer join between two vertices tables using an equality comparison a id = b id the result table includes all rows from the left table for left table rows that have no match in the right table, any expression that reads columns from the right table with the alias b evaluates to null (while expressions that only read the table with the alias a remain non null as usual) the method must include a list of sql expressions ( resultattributeexpressions ) in the same column order for every non identifier column in the merged result table these sql expressions can add computations to columns or simply add aliases if no changes are needed each expression can reference columns from the primary table using the alias a or from the modification table using the alias b syntax outerjoinvertices( inputschema, inputverticestable, otherschema, otherverticestable, resultschema, resultverticestable, resultattributeexpressions \[ , ], \[ resultverticesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example perform a left outer join on two vertices tables and generate an index on the id column ocgraph outerjoinvertices( "sales", "customers", "sales", "profiles", "sales", "customers joined", new arraylist<>(list of( "a id as id", "a status as status", "b tier as tier" )), new arraylist<>(list of("id")), stmt ); collectneighbors for each vertex in a table, this method collects information on neighbors (identifier and any attributes) as an array of tuples for a specified direction ( in , out , or both ), the method aggregates tuples representing each neighboring vertex into an array the direction types are in — neighbors with edges pointing to the vertex (edges where destid = id ) out — neighbors that the vertex points to (edges where srcid = id ) both — union of in and out with neighbors from incoming ( destid = id ) and outgoing ( srcid = id ) edges the result table has the columns id (the vertex identifier) and neighbors (an array of tuples representing each neighbor) if an error occurs after table creation, the method drops the result table syntax collectneighbors( inputschema, inputverticestable, inputedgestable, resultschema, resulttable, direction, \[ resultindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example collect incoming neighbors for each vertex and generate an index on the id column the direction argument set to in collects neighbors pointing to id ocgraph collectneighbors( "sales", "customers", "purchases", "sales", "neighbors in", ocgraph edgedirection in, new arraylist<>(list of("id")), stmt ); collectedges for each vertex in a table, this method collects an array of adjacent edge rows based on the specified direction the result table has two columns id (the vertex identifier) and edges (an array of tuples, each tuple containing all columns from the edges table for a connected edge) the direction types are in — edges pointing to the vertex (edges where destid = id ) out — edges originating from the vertex (edges where srcid = id ) both — union of in and out that includes edges from incoming ( destid = id ) and outgoing ( srcid = id ) directions this direction retains duplicates if an error occurs after table creation, the method drops the result table syntax collectedges( inputschema, inputverticestable, inputedgestable, resultschema, resulttable, direction, \[ resultindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example collect outgoing edges for each vertex and generate an index for the id column the example sets the direction to out to collect edges from id ocgraph collectedges( "sales", "customers", "purchases", "sales", "outgoing edges", ocgraph edgedirection out, new arraylist<>(list of("id")), stmt ); algorithms high level graph algorithms that iterate over the graph structure to produce labels, components, or counts labelpropagation executes the https //en wikipedia org/wiki/label propagation algorithm (lpa) to assign community labels to vertices each vertex starts with its own identifier as its label for a number set by the maxiterations argument, each vertex updates its label to the most frequent label among its neighbors the algorithm determines ties by choosing the smallest label the algorithm uses temporary tables for intermediate results and drops these tables when the process completes or if it fails isolated vertices retain their initial label the final table stores id and label columns and can include indexes syntax labelpropagation( inputschema, inputverticestable, inputedgestable, resultschema, resultverticestable, maxiterations, \[ resultverticesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example run label propagation for 10 iterations and assign labels to vertices generate an index on the id column ocgraph labelpropagation( "sales", "customers", "purchases", "sales", "lpa labels", 10, new arraylist<>(list of("id")), stmt ); connectedcomponents identifies the connected components of an undirected graph this algorithm configures a pregel computation in which each vertex initially sets its component label equal to its own identifier id in each iteration, vertices send their component label to neighbors each vertex updates based on the aggregated minimum value of its current component label and any received values the process repeats until no more updates occur or when it reaches the maximum specified number of iterations ( maxiterations ) the result table maps each vertex id to its final component label syntax connectedcomponents( inputschema, inputverticestable, inputedgestable, resultschema, resultverticestable, maxiterations, \[ resultverticesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example compute connected components for a maximum of 20 iterations and generate an index on the id column ocgraph connectedcomponents( "sales", "customers", "purchases", "sales", "components", 20, new arraylist<>(list of("id")), stmt ); stronglyconnectedcomponents computes strongly connected components (scc) in a directed graph this method runs a recursive algorithm that partitions vertices into subsets where every vertex is reachable from other vertices in the same subset this method uses recursive partitioning the algorithm selects a pivot (typically the minimum identifier id ), computes its predecessor set (vertices that can reach the pivot), and its descendant sets (vertices reachable from the pivot) then, the method identifies the scc as their intersection, removes that scc from the graph, and recurses on the remainder until all vertices have been assigned to an scc the output contains columns for the id and component identifiers (the minimum id in the scc) the method creates temporary tables in the result schema to store intermediate results this method drops these tables when the computation completes or fails the final result table contains two columns id (vertex identifier) and component (the minimum vertex identifier in its scc subset) syntax stronglyconnectedcomponents( inputschema, inputverticestable, inputedgestable, resultschema, resultverticestable, \[ resultverticesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example compute the scc and generate an index on the id column ocgraph stronglyconnectedcomponents( "sales", "customers", "purchases", "sales", "scc", new arraylist<>(list of("id")), stmt ); trianglecount trianglecount identifies all 3 cycles (triangles) in the graph and counts how many distinct triangles each vertex participates in the algorithm first builds a canonical, undirected edge set by ensuring srcid < destid and removing duplicates to prevent double counting if your input edges are already canonicalized and deduplicated, use trianglecount runprecanonicalized to skip preprocessing for faster performance the method then counts triangles ( a , b , c ) where a < b < c by intersecting neighbor lists and aggregates per vertex participation to produce a result table with the id and triangle count columns run syntax trianglecount run( inputschema, inputverticestable, inputedgestable, resultschema, resultverticestable, \[ resultverticesindexes \[ , ] ], stmt ) runprecanonicalized syntax trianglecount runprecanonicalized( inputschema, inputverticestable, canonicaledgestable, resultschema, resultverticestable, \[ resultverticesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type examples count triangles using run canonicalize the raw edges internally, count unique triangles, and write per vertex triangle counts with an index on the id column ocgraph trianglecount run( "sales", "customers", "purchases", "sales", "triangle counts", new arraylist<>(list of("id")), stmt ); count triangles using runprecanonicalized use a pre canonicalized, deduplicated edge table to count triangles and write per vertex triangle counts with an index on the id column ocgraph trianglecount runprecanonicalized( "sales", "customers", "purchases canonical", "sales", "triangle counts", new arraylist<>(list of("id")), stmt ); pregel provides a generic vertex‑centered iteration framework for custom graph algorithms, similar to the https //research google/pubs/pregel a system for large scale graph processing/ each iteration updates vertex states by sending messages along edges and then aggregating these messages to compute new states the algorithm continues iterating until it reaches convergence (no state changed or no messages produced) or a specified iteration cap the algorithm uses multiple specified sql expressions syntax pregel( inputschema, inputverticestable, inputedgestable, resultschema, resultverticestable, initializerexpr, \[ sendtosourceexpr ], \[ sendtodestexpr ], aggregateexpr, updaterexpr, maxiterations, \[ resultverticesindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example run a simple pregel computation summing incoming edge amounts into the vertex state for 10 iterations at most, and generate an index on the id column ocgraph pregel( "sales", "customers", "purchases", "sales", "pregel result", "0 as state", "b amount", null, "sum(msg) as aggregated message", "state + coalesce(aggregated message, 0) as state", 10, new arraylist<>(list of("id")), stmt ); paths and ranking these methods include the shortest path and pagerank algorithms shortestpaths computes the shortest distance from every vertex to each set of landmark vertices using an iterative relaxation algorithm the algorithm resembles https //en wikipedia org/wiki/bellman%e2%80%93ford algorithm but simultaneously handles multiple destinations each landmark starts at distance 0 and all others at positive infinity on each iteration, the algorithm examines every edge and checks whether traveling through the connected neighbor would yield a shorter route to a landmark if a shorter route exists, the algorithm updates the distance of the source vertex the process stops when no distances improve, or the algorithm reaches the maximum number of iterations after the process finishes, the algorithm writes a result table with the srcid , destid , and distance columns syntax shortestpaths( inputschema, inputverticestable, inputedgestable, resultschema, resulttable, landmarks \[ , ], \[ edgeweightcolumn ], maxiterations, \[ resultindexes \[ , ] ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example compute distances from landmarks and generate indexes on the src and dest columns ocgraph shortestpaths( "sales", "customers", "purchases", "sales", "distances", new arraylist<>(list of(1l, 42l)), null, // unweighted 10, new arraylist<>(list of("srcid","destid")), stmt ); staticpagerank computes https //en wikipedia org/wiki/pagerank scores for each vertex over a fixed number of iterations the algorithm follows the standard pagerank formula with a reset probability ( resetprob ) and uses common table expressions to calculate contributions from incoming edges and redistribute rank from dangling nodes the algorithm supports two variants standard pagerank — all vertices start with rank 1 0/n , where n is the number of vertices specify this variant if personalizationsrcid is null personalized pagerank — the specified vertex starts with a rank of 1 0 , while others start with a rank of 0 0 specify this variant if personalizationsrcid is a vertex identifier after running pagerank for a fixed number of iterations, the method writes a result vertices table containing all original vertex columns with a new pagerank scoring column syntax staticpagerank( inputschema, inputverticestable, inputedgestable, resultschema, resultverticestable, numiterations, resetprob, \[ resultverticesindexes \[ , ] ], \[ personalizationsrcid ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example run fixed iteration pagerank and generate an index on the id column this example uses a high reset probability resetprob of 0 85 to ensure the ranking concentrates on highly linked regions ocgraph staticpagerank( "sales", "customers", "purchases", "sales", "pagerank static", 10, 0 85, new arraylist<>(list of("id")), null, stmt ); dynamicpagerank computes pagerank scores until convergence based on a specified threshold value ( tolerance ) unlike the docid\ hoxig9l4m5f2kisrve3ge method, this algorithm runs iterations until the sum of absolute differences between ranks in successive iterations is less than or equal to the tolerance value the algorithm handles personalization similarly to staticpagerank at each iteration, the method uses the pagerank formula, collects rank values, and redistributes them the algorithm supports two variants standard pagerank — all vertices start with rank 1 0/n , where n is the number of vertices specify this variant if personalizationsrcid is null personalized pagerank — the specified vertex starts with a rank of 1 0 , while others start with a rank of 0 0 specify this variant if personalizationsrcid is a vertex identifier after running pagerank until the system reaches the tolerance threshold, the method writes a vertices table containing all the original vertex columns with a new pagerank scoring column syntax dynamicpagerank( inputschema, inputverticestable, inputedgestable, resultschema, resultverticestable, tolerance, resetprob, \[ resultverticesindexes \[ , ] ], \[ personalizationsrcid ], stmt ) true 200,200,201left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example run dynamic pagerank to convergence this example uses a low tolerance value of 1 0e 6 , which generates high precision rankings but requires more computing resources ocgraph dynamicpagerank( "sales", "customers", "purchases", "sales", "pagerank dynamic", 1 0e 6, 0 85, new arraylist<>(list of("id")), null, stmt ); bibliography pregel a system for large scale graph processing ” accessed november 18, 2025 https //research google/pubs/pregel a system for large scale graph processing/ related links docid apnndn tjqmjdd5oqdvd docid\ hnemo4f1y3sslallr03vp