tf_graph_shortest_path
Given a distance-weighted directed graph, consisting of a queryCURSOR input consisting of the starting and ending node for each edge and a distance, and a specified origin and destination node, tf_graph_shortest_path computes the shortest distance-weighted path through the graph between origin_node and destination_node, returning a row for each node along the computed shortest path, with the traversal-ordered index of that node and the cumulative distance from the origin_node to that node. If either origin_node or destination_node do not exist, an error is returned.
SELECT * FROM TABLE(
tf_graph_shortest_path(
edge_list => CURSOR(
SELECT node1, node2, distance FROM table
),
origin_node => <origin node>,
destination_node => <destination node>
)Input Arguments
node1
Origin node column in directed edge list CURSOR
Column< INT | BIGINT | TEXT ENCODED DICT>
node2
Destination node column in directed edge list CURSOR
Column< INT | BIGINT | TEXT ENCODED DICT> (must be the same type as node1)
distance
Distance between origin and destination node in directed edge list CURSOR
Column< INT | BIGINT | FLOAT | DOUBLE >
origin_node
The origin node to start graph traversal from. If not a value present in edge_list.node1, will cause empty result set to be returned.
BIGINT | TEXT ENCODED DICT
destination_node
The destination node to finish graph traversal at. If not a value present in edge_list.node1, will cause empty result set to be returned.
BIGINT | TEXT ENCODED DICT
Output Columns
path_step
The index of this node along the path traversal from origin_node to destination_node, with the first node (the origin_node) indexed as 1.
Column< INT >
node
The current node along the path traversal from origin_node to destination_node. The first node (as denoted by path_step = 1) will always be the input origin_node, and the final node (as denoted by MAX(path_step)) will always be the input destination_node.
Column < INT | BIGINT | TEXT ENCODED DICT> (same type as the node1 and node2 input columns)
cume_distance
The cumulative distance adding all input distance values from the origin_node to the current node.
Column < INT | BIGINT | FLOAT | DOUBLE> (same type as the distance input column)
Example A
Example B

Last updated