Version:

/create/graph

URL: http://GPUDB_IP_ADDRESS:GPUDB_PORT/create/graph

Creates a new graph network using given nodes, edges, weights, and restrictions.

IMPORTANT: It's highly recommended that you review the Network Graphs & Solvers concepts documentation, the Graph REST Tutorial, and/or some graph examples before using this endpoint.

Input Parameter Description

Name Type Description
graph_name string Name of the graph resource to generate.
directed_graph boolean

If set to true, the graph will be directed. If set to false, the graph will not be directed. Consult Directed Graphs for more details. The default value is true. The supported values are:

  • true
  • false
nodes array of strings Nodes represent fundamental topological units of a graph. Nodes must be specified using identifiers; identifiers are grouped as combinations. Identifiers can be used with existing column names, e.g., 'table.column AS NODE_ID', expressions, e.g., 'ST_MAKEPOINT(column1, column2) AS NODE_WKTPOINT', or constant values, e.g., '{9, 10, 11} AS NODE_ID'. If using constant values in an identifier combination, the number of values specified must match across the combination.
edges array of strings Edges represent the required fundamental topological unit of a graph that typically connect nodes. Edges must be specified using identifiers; identifiers are grouped as combinations. Identifiers can be used with existing column names, e.g., 'table.column AS EDGE_ID', expressions, e.g., 'SUBSTR(column, 1, 6) AS EDGE_NODE1_NAME', or constant values, e.g., "{'family', 'coworker'} AS EDGE_LABEL". If using constant values in an identifier combination, the number of values specified must match across the combination.
weights array of strings Weights represent a method of informing the graph solver of the cost of including a given edge in a solution. Weights must be specified using identifiers; identifiers are grouped as combinations. Identifiers can be used with existing column names, e.g., 'table.column AS WEIGHTS_EDGE_ID', expressions, e.g., 'ST_LENGTH(wkt) AS WEIGHTS_VALUESPECIFIED', or constant values, e.g., '{4, 15} AS WEIGHTS_VALUESPECIFIED'. If using constant values in an identifier combination, the number of values specified must match across the combination.
restrictions array of strings Restrictions represent a method of informing the graph solver which edges and/or nodes should be ignored for the solution. Restrictions must be specified using identifiers; identifiers are grouped as combinations. Identifiers can be used with existing column names, e.g., 'table.column AS RESTRICTIONS_EDGE_ID', expressions, e.g., 'column/2 AS RESTRICTIONS_VALUECOMPARED', or constant values, e.g., '{0, 0, 0, 1} AS RESTRICTIONS_ONOFFCOMPARED'. If using constant values in an identifier combination, the number of values specified must match across the combination.
options map of string to strings

Optional parameters. The default value is an empty map ( {} ).

Supported Parameters (keys) Parameter Description
restriction_threshold_value Value-based restriction comparison. Any node or edge with a RESTRICTIONS_VALUECOMPARED value greater than the restriction_threshold_value will not be included in the graph.
merge_tolerance If node geospatial positions are input (e.g., WKTPOINT, 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-4'.
min_x Minimum x (longitude) value for spatial graph associations. The default value is '-180.0'.
max_x Maximum x (longitude) value for spatial graph associations. The default value is '180.0'.
min_y Minimum y (latitude) value for spatial graph associations. The default value is '-90.0'.
max_y Maximum y (latitude) value for spatial graph associations. The default value is '90.0'.
recreate

If set to true and the graph (using input parameter graph_name) already exists, the graph is deleted and recreated. The default value is false. The supported values are:

  • true
  • false
modify

If set to true, recreate is set to true, and the graph (specified using input parameter graph_name) already exists, the graph is updated with the given components. The default value is false. The supported values are:

  • true
  • false
export_create_results

If set to true, returns the graph topology in the response as arrays. The default value is false. The supported values are:

  • true
  • false
enable_graph_draw

If set to true, adds a 'EDGE_WKTLINE' column identifier to the specified graph_table so the graph can be viewed via WMS; for social and non-geospatial graphs, the 'EDGE_WKTLINE' column identifier will be populated with spatial coordinates derived from a flattening layout algorithm so the graph can still be viewed. The default value is false. The supported values are:

  • true
  • false
save_persist

If 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. The supported values are:

  • true
  • false
sync_db

If set to true and save_persist is set to true, the graph will be fully reconstructed upon a database restart and be updated to align with any source table(s) updates made since the creation of the graph. If dynamic graph updates upon table inserts are desired, use add_table_monitor instead. The default value is false. The supported values are:

  • true
  • false
add_table_monitor

Adds 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 /create/tablemonitor. The default value is false. The supported values are:

  • true
  • false
graph_table If specified, the created graph is also created as a table with the given name and following identifier columns: 'EDGE_ID', 'EDGE_NODE1_ID', 'EDGE_NODE2_ID'. If left blank, no table is created. The default value is ''.
remove_label_only

When RESTRICTIONS on labeled entities requested, if set to true this will NOT delete the entity but only the label associated with the entity. Otherwise (default), it'll delete the label AND the entity. The default value is false. The supported values are:

  • true
  • false
add_turns

Adds 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. The supported values are:

  • true
  • false
turn_angle Value in degrees modifies the thresholds for attributing right, left, sharp turns, and intersections. It is the vertical deviation angle from the incoming edge to the intersection node. The larger the value, the larger the threshold for sharp turns and intersections; the smaller the value, the larger the threshold for right and left turns; 0 < turn_angle < 90. The default value is '60'.

Output Parameter Description

The GPUdb server embeds the endpoint response inside a standard response structure which contains status information and the actual response to the query. Here is a description of the various fields of the wrapper:

Name Type Description
status String 'OK' or 'ERROR'
message String Empty if success or an error message
data_type String 'create_graph_request' or 'none' in case of an error
data String Empty string
data_str JSON or String

This embedded JSON represents the result of the /create/graph endpoint:

Name Type Description
num_nodes long Total number of nodes created.
num_edges long Total number of edges created.
edges_ids array of longs Edges given as pairs of node indices. Only populated if export_create_results is set to true.
info map of string to strings Additional information.

Empty string in case of an error.