Version:

/solve/graph

URL: http://GPUDB_IP_ADDRESS:GPUDB_PORT/solve/graph

Solves an existing graph for a type of problem (e.g., shortest path, page rank, travelling salesman, etc.) using source nodes, destination nodes, and additional, optional weights and restrictions. See Network Graph Solvers for more information.

Input Parameter Description

Name Type Description
graph_name string Name of the graph resource to solve.
weights_on_edges array of strings Additional weights to apply to the edges of an existing graph. 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 raw values, e.g., '{4, 15, 2} AS WEIGHTS_VALUESPECIFIED'. Any provided weights will be added (in the case of 'WEIGHTS_VALUESPECIFIED') to or multiplied with (in the case of 'WEIGHTS_FACTORSPECIFIED') the existing weight(s). If using raw values in an identifier combination, the number of values specified must match across the combination. The default value is an empty array ( [] ).
restrictions array of strings Additional restrictions to apply to the nodes/edges of an existing graph. 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 raw values, e.g., '{0, 0, 0, 1} AS RESTRICTIONS_ONOFFCOMPARED'. If using raw values in an identifier combination, the number of values specified must match across the combination. If remove_previous_restrictions is set to true, any provided restrictions will replace the existing restrictions. If remove_previous_restrictions is set to false, any provided restrictions will be added (in the case of 'RESTRICTIONS_VALUECOMPARED') to or replaced (in the case of 'RESTRICTIONS_ONOFFCOMPARED'). The default value is an empty array ( [] ).
solver_type string

The type of solver to use for the graph.

Supported Values Description
SHORTEST_PATH Solves for the optimal (shortest) path based on weights and restrictions from one source to destinations nodes. Also known as the Dijkstra solver.
PAGE_RANK Solves for the probability of each destination node being visited based on the links of the graph topology. Weights are not required to use this solver.
PROBABILITY_RANK Solves for the transitional probability (Hidden Markov) for each node based on the weights (probability assigned over given edges).
CENTRALITY Solves for the degree of a node to depict how many pairs of individuals that would have to go through the node to reach one another in the minimum number of hops. Also known as betweenness.
MULTIPLE_ROUTING Solves for finding the minimum cost cumulative path for a round-trip starting from the given source and visiting each given destination node once then returning to the source. Also known as the travelling salesman problem.
INVERSE_SHORTEST_PATH Solves for finding the optimal path cost for each destination node to route to the source node. Also known as inverse Dijkstra or the service man routing problem.
BACKHAUL_ROUTING Solves for optimal routes that connect remote asset nodes to the fixed (backbone) asset nodes. When BACKHAUL_ROUTING is invoked, the input parameter destination_nodes or input parameter destination_node_ids array is used for both fixed and remote asset nodes and the input parameter source_node_id represents the number of fixed asset nodes contained in input parameter destination_nodes / input parameter destination_node_ids.
source_node_id long If input parameter node_type is NODE_ID, the node ID (integer) of the source (starting point) for the graph solution. If the input parameter solver_type is set to BACKHAUL_ROUTING, this number represents the number of fixed asset nodes contained in input parameter destination_nodes, e.g., if input parameter source_node_id is set to 24, the first 24 nodes listed in input parameter destination_nodes / input parameter destination_node_ids are the fixed asset nodes and the rest of the nodes in the array are remote assets.
destination_node_ids array of longs List of destination node indices, or indices for pageranks. If the input parameter solver_type is set to BACKHAUL_ROUTING, it is the list of all fixed and remote asset nodes. The default value is an empty array ( [] ).
node_type string

Source and destination node identifier type.

Supported Values Description
NODE_ID The graph's nodes were identified as integers, e.g., 1234.
NODE_WKTPOINT The graph's nodes were identified as geospatial coordinates, e.g., 'POINT(1.0 2.0)'.
NODE_NAME The graph's nodes were identified as strings, e.g., 'Arlington'.
source_node string If input parameter node_type is NODE_WKTPOINT or NODE_NAME, the node (string) of the source (starting point) for the graph solution. The default value is ''.
destination_nodes array of strings If input parameter node_type is NODE_WKTPOINT or NODE_NAME, the list of destination node or page rank indices (strings) for the graph solution. If the input parameter solver_type is set to BACKHAUL_ROUTING, it is the list of all fixed and remote asset nodes. The string type should be consistent with the input parameter node_type parameter. The default value is an empty array ( [] ).
solution_table string Name of the table to store the solution. The default value is 'graph_solutions'.
options map of string to strings

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

Supported Parameters (keys) Parameter Description
max_solution_radius For SHORTEST_PATH and INVERSE_SHORTEST_PATH solvers only. Sets the maximum solution cost radius, which ignores the input parameter destination_node_ids list and instead outputs the nodes within the radius sorted by ascending cost. If set to '0.0', the setting is ignored. The default value is '0.0'.
min_solution_radius For SHORTEST_PATH and INVERSE_SHORTEST_PATH solvers only. Applicable only when max_solution_radius is set. Sets the minimum solution cost radius, which ignores the input parameter destination_node_ids list and instead outputs the nodes within the radius sorted by ascending cost. If set to '0.0', the setting is ignored. The default value is '0.0'.
max_solution_targets For SHORTEST_PATH and INVERSE_SHORTEST_PATH solvers only. Sets the maximum number of solution targets, which ignores the input parameter destination_node_ids list and instead outputs no more than n number of nodes sorted by ascending cost where n is equal to the setting value. If set to 0, the setting is ignored. The default value is '0'.
export_solve_results

Returns solution results inside the output parameter result_per_destination_node array in the response if set to true. The supported values are:

  • true
  • false
remove_previous_restrictions

Ignore the restrictions applied to the graph during the creation stage and only use the restrictions specified in this request if set to true. The supported values are:

  • true
  • false
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 solution.
uniform_weights When specified, assigns the given value to all the edges in the graph. Note that weights provided in input parameter weights_on_edges will override this value.

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 'solve_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 /solve/graph endpoint:

Name Type Description
result boolean Indicates a successful solution.
result_per_destination_node array of floats Cost or Pagerank (based on solver type) for each destination node requested. Only populated if export_solve_results is set to true.
info map of string to strings Additional information.

Empty string in case of an error.