> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# /match/graph

```
URL: http://<db.host>:<db.port>/match/graph
```

Matches a directed route implied by a given set of latitude/longitude points to
an existing underlying road network graph using a given solution type.

IMPORTANT: It's highly recommended that you review the
[Graphs and Solvers](../../graph_solver/network_graph_solver/) concepts
documentation, the [Graph REST Tutorial](../../guides/graph_rest_guide/),
and/or some [/match/graph examples](/content/guides/tags/graph-match)
before using this endpoint.

## Input Parameter Description

<ParamField body="graph_name" type="string">
  Name of the underlying geospatial graph resource to match to using input parameter *sample\_points*.
</ParamField>

<ParamField body="sample_points" type="array of strings">
  Sample points used to match to an underlying geospatial graph. Sample points must be specified using [identifiers](../../graph_solver/network_graph_solver/#match-identifiers); identifiers are grouped as [combinations](../../graph_solver/network_graph_solver/#match-combinations). Identifiers can be used with: existing column names, e.g., 'table.column AS SAMPLE\_X'; expressions, e.g., 'ST\_MAKEPOINT(table.x, table.y) AS SAMPLE\_WKTPOINT'; or constant values, e.g., '\{1, 2, 10} AS SAMPLE\_TRIPID'.
</ParamField>

<ParamField body="solve_method" type="string">
  The type of solver to use for graph matching.

  The default value is `markov_chain`.

  * **markov\_chain**: Matches input parameter *sample\_points* to the graph using the Hidden Markov Model (HMM)-based method, which conducts a range-tree closest-edge search to find the best combinations of possible road segments (*num\_segments*) for each sample point to create the best route. The route is secured one point at a time while looking ahead *chain\_width* number of points, so the prediction is corrected after each point. This solution type is the most accurate but also the most computationally intensive. Related options: *num\_segments* and *chain\_width*.
  * **match\_od\_pairs**: Matches input parameter *sample\_points* to find the most probable path between origin and destination pairs with cost constraints.
  * **match\_supply\_demand**: Matches input parameter *sample\_points* to optimize scheduling multiple supplies (trucks) with varying sizes to varying demand sites with varying capacities per depot. Related options: *partial\_loading* and *max\_combinations*.
  * **match\_batch\_solves**: Matches input parameter *sample\_points* source and destination pairs for the shortest path solves in batch mode.
  * **match\_loops**: Matches closed loops (Eulerian paths) originating and ending at each graph node within min and max hops (levels).
  * **match\_charging\_stations**: Matches an optimal path across a number of ev-charging stations between source and target locations.
  * **match\_similarity**: Matches the intersection set(s) by computing the Jaccard similarity score between node pairs.
  * **match\_pickup\_dropoff**: Matches the pickups and dropoffs by optimizing the total trip costs.
  * **match\_clusters**: Matches the graph nodes with a cluster index using Louvain clustering algorithm.
  * **match\_pattern**: Matches a pattern in the graph.
  * **match\_embedding**: Creates vector node embeddings.
  * **match\_isochrone**: Solves for isochrones for a set of input sources.
  * **match\_route\_detour**: Computes detour costs for nearby stations at a mark point along each source-target route.
</ParamField>

<ParamField body="solution_table" type="string">
  The name of the table used to store the results, in \[schema\_name.]table\_name format, using standard [name resolution rules](../../concepts/tables/#table-name-resolution) and meeting [table naming criteria](../../concepts/tables/#table-naming-criteria). This table contains a [track](../../location_intelligence/geo_objects/#geospatial-tracks) of geospatial points for the matched portion of the graph, a track ID, and a score value. Also outputs a details table containing a trip ID (that matches the track ID), the latitude/longitude pair, the timestamp the point was recorded at, and an edge ID corresponding to the matched road segment. Must not be an existing table of the same name.

  The default value is ''.
</ParamField>

<ParamField body="options" type="map of string to strings">
  Additional parameters.

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

  <Expandable title="options">
    <ParamField body="gps_noise">
      GPS noise value (in meters) to remove redundant sample points. Use -1 to disable noise reduction. The default value accounts for 95% of point variation (+ or -5 meters).

      The default value is `5.0`.
    </ParamField>

    <ParamField body="num_segments">
      Maximum number of potentially matching road segments for each sample point. For the *markov\_chain* solver, the default is 3.

      The default value is `3`.
    </ParamField>

    <ParamField body="search_radius">
      Maximum search radius used when snapping sample points onto potentially matching surrounding segments. The default value corresponds to approximately 100 meters.

      The default value is `0.001`.
    </ParamField>

    <ParamField body="chain_width">
      For the *markov\_chain* solver only. Length of the sample points lookahead window within the Markov kernel; the larger the number, the more accurate the solution.

      The default value is `9`.
    </ParamField>

    <ParamField body="source">
      WKT starting point from input parameter *sample\_points* for the solver. The default behavior for the endpoint is to use time to determine the starting point.

      The default value is `POINT NULL`.
    </ParamField>

    <ParamField body="destination">
      WKT ending point from input parameter *sample\_points* for the solver. The default behavior for the endpoint is to use time to determine the destination point.

      The default value is `POINT NULL`.
    </ParamField>

    <ParamField body="partial_loading">
      For the *match\_supply\_demand* solver only. When false (non-default), trucks do not off-load at the demand (store) side if the remainder is less than the store's need.

      The default value is `true`.

      * **true**: Partial off-loading at multiple store (demand) locations.
      * **false**: No partial off-loading allowed if supply is less than the store's demand.
    </ParamField>

    <ParamField body="max_combinations">
      For the *match\_supply\_demand* solver only. This is the cutoff for the number of generated combinations for sequencing the demand locations - can increase this up to 2M.

      The default value is `10000`.
    </ParamField>

    <ParamField body="max_supply_combinations">
      For the *match\_supply\_demand* solver only. This is the cutoff for the number of generated combinations for sequencing the supply locations if/when 'permute\_supplies' is true.

      The default value is `10000`.
    </ParamField>

    <ParamField body="left_turn_penalty">
      This will add an additional weight over the edges labeled as 'left turn' if the 'add\_turn' option parameter of the [/create/graph](/content/api/rest/create_graph_rest) was invoked at graph creation.

      The default value is `0.0`.
    </ParamField>

    <ParamField body="right_turn_penalty">
      This will add an additional weight over the edges labeled as' right turn' if the 'add\_turn' option parameter of the [/create/graph](/content/api/rest/create_graph_rest) was invoked at graph creation.

      The default value is `0.0`.
    </ParamField>

    <ParamField body="intersection_penalty">
      This will add an additional weight over the edges labeled as 'intersection' if the 'add\_turn' option parameter of the [/create/graph](/content/api/rest/create_graph_rest) was invoked at graph creation.

      The default value is `0.0`.
    </ParamField>

    <ParamField body="sharp_turn_penalty">
      This will add an additional weight over the edges labeled as 'sharp turn' or 'u-turn' if the 'add\_turn' option parameter of the [/create/graph](/content/api/rest/create_graph_rest) was invoked at graph creation.

      The default value is `0.0`.
    </ParamField>

    <ParamField body="aggregated_output">
      For the *match\_supply\_demand* solver only. When it is true (default), each record in the output table shows a particular truck's scheduled cumulative round trip path (MULTILINESTRING) and the corresponding aggregated cost. Otherwise, each record shows a single scheduled truck route (LINESTRING) towards a particular demand location (store id) with its corresponding cost.

      The default value is `true`.
    </ParamField>

    <ParamField body="output_tracks">
      For the *match\_supply\_demand* solver only. When it is true (non-default), the output will be in tracks format for all the round trips of each truck in which the timestamps are populated directly from the edge weights starting from their originating depots.

      The default value is `false`.
    </ParamField>

    <ParamField body="max_trip_cost">
      For the *match\_supply\_demand* and *match\_pickup\_dropoff* solvers only. If this constraint is greater than zero (default) then the trucks/rides will skip traveling from one demand/pick location to another if the cost between them is greater than this number (distance or time). Zero (default) value means no check is performed.

      The default value is `0.0`.
    </ParamField>

    <ParamField body="filter_folding_paths">
      For the *markov\_chain* solver only. When true (non-default), the paths per sequence combination is checked for folding over patterns and can significantly increase the execution time depending on the chain width and the number of GPS samples.

      The default value is `false`.

      * **true**: Filter out the folded paths.
      * **false**: Do not filter out the folded paths.
    </ParamField>

    <ParamField body="unit_unloading_cost">
      For the *match\_supply\_demand* solver only. The unit cost per load amount to be delivered. If this value is greater than zero (default) then the additional cost of this unit load multiplied by the total dropped load will be added over to the trip cost to the demand location.

      The default value is `0.0`.
    </ParamField>

    <ParamField body="max_num_threads">
      For the *markov\_chain* solver only. If specified (greater than zero), the maximum number of threads will not be greater than the specified value. It can be lower due to the memory and the number cores available. Default value of zero allows the algorithm to set the maximal number of threads within these constraints.

      The default value is `0`.
    </ParamField>

    <ParamField body="service_limit">
      For the *match\_supply\_demand* solver only. If specified (greater than zero), any supply actor's total service cost (distance or time) will be limited by the specified value including multiple rounds (if set).

      The default value is `0.0`.
    </ParamField>

    <ParamField body="enable_reuse">
      For the *match\_supply\_demand* solver only. If specified (true), all supply actors can be scheduled for second rounds from their originating depots.

      The default value is `false`.

      * **true**: Allows reusing supply actors (trucks, e.g.) for scheduling again.
      * **false**: Supply actors are scheduled only once from their depots.
    </ParamField>

    <ParamField body="max_stops">
      For the *match\_supply\_demand* solver only. If specified (greater than zero), a supply actor (truck) can at most have this many stops (demand locations) in one round trip. Otherwise, it is unlimited. If 'enable\_truck\_reuse' is on, this condition will be applied separately at each round trip use of the same truck.

      The default value is `0`.
    </ParamField>

    <ParamField body="service_radius">
      For the *match\_supply\_demand* and *match\_pickup\_dropoff* solvers only. If specified (greater than zero), it filters the demands/picks outside this radius centered around the supply actor/ride's originating location (distance or time).

      The default value is `0.0`.
    </ParamField>

    <ParamField body="permute_supplies">
      For the *match\_supply\_demand* solver only. If specified (true), supply side actors are permuted for the demand combinations during MSDO optimization - note that this option increases optimization time significantly - use of 'max\_combinations' option is recommended to prevent prohibitively long runs.

      The default value is `true`.

      * **true**: Generates sequences over supply side permutations if total supply is less than twice the total demand.
      * **false**: Permutations are not performed, rather a specific order of supplies based on capacity is computed.
    </ParamField>

    <ParamField body="batch_tsm_mode">
      For the *match\_supply\_demand* solver only. When enabled, it sets the number of visits on each demand location by a single salesman at each trip is considered to be (one) 1, otherwise there is no bound.

      The default value is `false`.

      * **true**: Sets only one visit per demand location by a salesman (TSM mode).
      * **false**: No preset limit (usual MSDO mode).
    </ParamField>

    <ParamField body="round_trip">
      For the *match\_supply\_demand* solver only. When enabled, the supply will have to return back to the origination location.

      The default value is `true`.

      * **true**: The optimization is done for trips in round trip manner always returning to originating locations.
      * **false**: Supplies do not have to come back to their originating locations in their routes. The routes are considered finished at the final dropoff.
    </ParamField>

    <ParamField body="num_cycles">
      For the *match\_clusters* solver only. Terminates the cluster exchange iterations across 2-step-cycles (outer loop) when quality does not improve during iterations.

      The default value is `10`.
    </ParamField>

    <ParamField body="num_loops_per_cycle">
      For the *match\_clusters* and *match\_embedding* solvers only. Terminates the cluster exchanges within the first step iterations of a cycle (inner loop) unless convergence is reached.

      The default value is `10`.
    </ParamField>

    <ParamField body="num_output_clusters">
      For the *match\_clusters* solver only.  Limits the output to the top 'num\_output\_clusters' clusters based on density. Default value of zero outputs all clusters.

      The default value is `0`.
    </ParamField>

    <ParamField body="max_num_clusters">
      For the *match\_clusters* and *match\_embedding* solvers only. If set (value greater than zero), it terminates when the number of clusters goes below than this number. For embedding solver the default is 8.

      The default value is `0`.
    </ParamField>

    <ParamField body="cluster_quality_metric">
      For the *match\_clusters* solver only. The quality metric for Louvain modularity optimization solver.

      The default value is `girvan`.

      * **girvan**: Uses the Newman Girvan quality metric for cluster solver.
      * **spectral**: Applies recursive spectral bisection (RSB) partitioning solver.
    </ParamField>

    <ParamField body="restricted_type">
      For the *match\_supply\_demand* solver only. Optimization is performed by restricting routes labeled by 'MSDO\_ODDEVEN\_RESTRICTED' only for this supply actor (truck) type.

      The default value is `none`.

      * **odd**: Applies odd/even rule restrictions to odd tagged vehicles.
      * **even**: Applies odd/even rule restrictions to even tagged vehicles.
      * **none**: Does not apply odd/even rule restrictions to any vehicles.
    </ParamField>

    <ParamField body="server_id">
      Indicates which graph server(s) to send the request to. Default is to send to the server, amongst those containing the corresponding graph, that has the most computational bandwidth.

      The default value is ''.
    </ParamField>

    <ParamField body="inverse_solve">
      For the *match\_batch\_solves* solver only. Solves source-destination pairs using inverse shortest path solver.

      The default value is `false`.

      * **true**: Solves using inverse shortest path solver.
      * **false**: Solves using direct shortest path solver.
    </ParamField>

    <ParamField body="min_loop_level">
      For the *match\_loops* solver only. Finds closed loops around each node deducible not less than this minimal hop (level) deep.

      The default value is `0`.
    </ParamField>

    <ParamField body="max_loop_level">
      For the *match\_loops* solver only. Finds closed loops around each node deducible not more than this maximal hop (level) deep.

      The default value is `5`.
    </ParamField>

    <ParamField body="search_limit">
      For the *match\_loops* solver only. Searches within this limit of nodes per vertex to detect loops. The value zero means there is no limit.

      The default value is `10000`.
    </ParamField>

    <ParamField body="output_batch_size">
      For the *match\_loops* solver only. Uses this value as the batch size of the number of loops in flushing(inserting) to the output table.

      The default value is `1000`.
    </ParamField>

    <ParamField body="multi_step">
      For the *match\_supply\_demand* solver only. Runs multiple supply demand solver repeatedly in a multi step cycle by switching supplies to demands until it reaches the main hub supply.

      The default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="charging_capacity">
      For the *match\_charging\_stations* solver only. This is the maximum ev-charging capacity of a vehicle (distance in meters or time in seconds depending on the unit of the graph weights).

      The default value is `300000.0`.
    </ParamField>

    <ParamField body="charging_candidates">
      For the *match\_charging\_stations* solver only. Solver searches for this many number of stations closest around each base charging location found by capacity.

      The default value is `10`.
    </ParamField>

    <ParamField body="charging_penalty">
      For the *match\_charging\_stations* solver only. This is the penalty for full charging.

      The default value is `30000.0`.
    </ParamField>

    <ParamField body="detour_mark_cost">
      For the *match\_route\_detour* solver only. Cost along the route at which to search for nearby stations If zero, it solves along the trip sliding the 3 SSSP cycle kernel by radius amount.

      The default value is `3600.0`.
    </ParamField>

    <ParamField body="detour_reentry_factor">
      For the *match\_route\_detour* solver only. Multiplier on detour\_mark\_cost to determine the reentry point on the route (default 1.2 means 20% further along).

      The default value is `1.2`.
    </ParamField>

    <ParamField body="detour_search_radius">
      For the *match\_route\_detour* solver only. Search radius around the mark point for finding nearby prospective stations (e.g. cafes, pit stops, EV charging stations).

      The default value is `600.0`.
    </ParamField>

    <ParamField body="detour_search_limit">
      For the *match\_route\_detour* solver only. Maximum number of nearby stations to consider within the search radius around the mark point.

      The default value is `10`.
    </ParamField>

    <ParamField body="max_hops">
      For the *match\_similarity* and *match\_embedding* solvers only. Searches within this maximum hops for source and target node pairs to compute the Jaccard scores.

      The default value is `3`.
    </ParamField>

    <ParamField body="traversal_node_limit">
      For the *match\_similarity* solver only. Limits the traversal depth if it reaches this many number of nodes.

      The default value is `1000`.
    </ParamField>

    <ParamField body="paired_similarity">
      For the *match\_similarity* solver only. If true, it computes Jaccard score between each pair, otherwise it will compute Jaccard from the intersection set between the source and target nodes.

      The default value is `true`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="force_undirected">
      For the *match\_pattern* and *match\_embedding* solvers only. Pattern matching will be using both pattern and graph as undirected if set to true.

      The default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="max_vector_dimension">
      For the *match\_embedding* solver only. Limits the number of dimensions in node vector embeddings.

      The default value is `1000`.
    </ParamField>

    <ParamField body="optimize_embedding_weights">
      For the *match\_embedding* solvers only. Solves to find the optimal weights per sub feature in vector embeddings.

      The default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="embedding_weights">
      For the *match\_embedding* solver only. User specified weights per sub feature in vector embeddings. The string contains the comma separated float values for each sub-feature in the vector space. These values will ONLY be used if 'optimize\_embedding\_weights' is false.

      The default value is `1.0,1.0,1.0,1.0`.
    </ParamField>

    <ParamField body="optimization_sampling_size">
      For the *match\_embedding* solver only. Sets the number of random nodes from the graph for solving the weights using stochastic gradient descent.

      The default value is `1000`.
    </ParamField>

    <ParamField body="optimization_max_iterations">
      For the *match\_embedding* solver only. When the iterations (epochs) for the convergence of the stochastic gradient descent algorithm reaches this number it bails out unless relative error between consecutive iterations is below the 'optimization\_error\_tolerance' option.

      The default value is `1000`.
    </ParamField>

    <ParamField body="optimization_error_tolerance">
      For the *match\_embedding* solver only. When the relative error between all of the weights' consecutive iterations falls below this threshold the optimization cycle is interrupted unless the number of iterations reaches the limit set by the option 'max\_optimization\_iterations'.

      The default value is `0.001`.
    </ParamField>

    <ParamField body="optimization_iteration_rate">
      For the *match\_embedding* solver only. It is otherwise known as the learning rate, which is the proportionality constant in front of the gradient term in successive iterations.

      The default value is `0.3`.
    </ParamField>

    <ParamField body="max_radius">
      For the *match\_isochrone* solver only. Sets the maximal reachability limit for computing isochrones. Zero means no limit.

      The default value is `0.0`.
    </ParamField>
  </Expandable>
</ParamField>

## Output Parameter Description

The Kinetica 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:

<ResponseField name="status" type="String">
  'OK' or 'ERROR'
</ResponseField>

<ResponseField name="message" type="String">
  Empty if success or an error message
</ResponseField>

<ResponseField name="data_type" type="String">
  'match\_graph\_response' or 'none' in case of an error
</ResponseField>

<ResponseField name="data" type="String">
  Empty string
</ResponseField>

<ResponseField name="data_str" type="JSON or String">
  This embedded JSON represents the result of the /match/graph endpoint:

  <Expandable title="data_str">
    <ResponseField name="result" type="boolean">
      Indicates a successful solution.
    </ResponseField>

    <ResponseField name="match_score" type="float">
      The mean square error calculation representing the map matching score. Values closer to zero are better.
    </ResponseField>

    <ResponseField name="info" type="map of string to strings">
      Additional information.
    </ResponseField>
  </Expandable>

  Empty string in case of an error.
</ResponseField>
