Skip to main content
Creates a new graph. The nodes and edges of a graph are optionally weighted and/or restricted to aid in calculating various ways to traverse the graph. Graphs comprise a maximum of four components that each have unique specifications and ways they can be combined to define the graph. Review Components and Identifiers and Identifier Combinations for more information.
CREATE GRAPH Syntax

Parameters

OR REPLACE

Any existing graph with the same name will be dropped before creating this one

DIRECTED

Optional keyword used to create the graph as directed

<schema name>

Name of the schema that will contain the created graph; if no schema is specified, the graph will be created in the calling user’s default schema

<graph name>

Name of the graph, which can be referenced in subsequent commands

EDGES

Graph component, provided as table column names, expressions, or constants using the SQL INPUT_TABLE or INPUT_TABLES function, to use for identifying the edges of the graph; review Components and Identifiers and Identifier Combinations for more information
The input can be either the name of a table with appropriately named columns; or a query, to use specific columns or other SQL features).

NODES

Optional graph component, provided as column names, expressions, or constants using the SQL INPUT_TABLE or INPUT_TABLES function, to use for identifying the nodes of the graph; review Components and Identifiers and Identifier Combinations for more information
The input can be either the name of a table with appropriately named columns; or a query, to use specific columns or other SQL features).

WEIGHTS

Optional graph component, provided as column names, expressions, or constants using the SQL INPUT_TABLE or INPUT_TABLES function, to use for identifying the weights of the graph; review Components and Identifiers and Identifier Combinations for more information
The input can be either the name of a table with appropriately named columns; or a query, to use specific columns or other SQL features).

RESTRICTIONS

Optional graph component, provided as column names, expressions, or constants using the SQL INPUT_TABLE or INPUT_TABLES function, to use for identifying the restrictions of the graph; review Components and Identifiers and Identifier Combinations for more information
The input can be either the name of a table with appropriately named columns; or a query, to use specific columns or other SQL features).

OPTIONS

Optional indicator that a list of connection option/value assignments will follow, passed as a comma-delimited list of key/value pairs to the KV_PAIRS function
OptionDescription
add_table_monitorAdds a table monitor to every table used in the creation of the graph; this table monitor will trigger the graph to update dynamically upon inserts to the source table(s). Note that upon database restart, if save_persist is also set to true, the graph will be fully reconstructed and the table monitors will be reattached. For more details on table monitors, see Table Monitors. The default value is false.
add_turnsAdds dummy “pillowed” edges around intersection nodes where there are more than three edges so that additional weight penalties can be imposed by the solve endpoints (increases the total number of edges). The default value is false.
allow_multiple_edgesEnables multigraph capability—pairs of nodes can be connected by more than one edge. Without this option, undirected graphs can only have one edge between each pair of nodes, and directed graphs can have one edge in each direction between each pair of nodes—“duplicate” edges are discarded.
cluster_graph_schemaIf export_graph_schema is true, outputs the graph’s schema into a table named <graph_name>_clusters
export_graph_schemaExports a graph’s schema in Graphviz DOT format. The schema is a conversion of the graph into a label-based ontology, done by grouping the nodes using the Louvain clustering algorithm. This schema is made available in two ways:
  • visually, by clicking {{< guilabel “View Schema” >}} in the result of an CREATE GRAPH command in a SQL Block within Workbench
  • as text, under the info and then dot keys of the response to a native API call to /execute/sql
graph_tableIf specified, the created graph is also created as a table with the given name, in [schema_name.]table_name format, using standard name resolution rules and meeting table naming criteria. The table will have the following identifier columns: EDGE_ID, EDGE_NODE1_ID, EDGE_NODE2_ID. If left blank, no table is created. The default value is blank.
is_partitionedIf set to true, the graph will be partitioned across the servers specified in server_id; if false, the graph will be replicated across those servers. The default value is false.
label_delimiterIf specified, the delimiter to use when parsing edge labels. All labels separated by this delimiter will be applied to the corresponding edge.
merge_toleranceIf node geospatial positions are input (e.g., POINT(X Y)), determines the minimum separation allowed between unique nodes. If nodes are within the tolerance of each other, they will be merged as a single node. The default value is 1.0E-5.
recreateIf set to true and the graph already exists, the graph is deleted and recreated. The default value is false.
save_persistIf set to true, the graph will be saved in the persist directory (see the config reference for more information). If set to false, the graph will be removed when the graph server is shutdown. The default value is false.
schema_edge_labelkeysIf export_graph_schema is true, generates the label-based schema by collapsing edges based on the their label keys; otherwise, schema edges are created from the edge labels.
schema_node_labelkeysIf export_graph_schema is true, generates the label-based schema by collapsing nodes based on the their label keys; otherwise, schema nodes are created from the node labels.
server_idIndicates on which graph server(s) to create the graph. Default is to create on the server with the most available memory. Can be a single server ID, a comma-separated list of IDs, or all for all servers.
simplifySimplifies the graph topology at 2-valence by collapsing edge.
use_rtreeUse a range tree structure to accelerate and improve the accuracy of snapping, especially to edges.

Examples