> ## 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.

# /query/graph

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

Employs a topological query on a graph generated a-priori by
[/create/graph](/content/api/rest/create_graph_rest) and returns a list of adjacent
edge(s) or node(s), also known as an adjacency list, depending on what's been
provided to the endpoint; providing edges will return nodes and providing nodes
will return edges.

To determine the node(s) or edge(s) adjacent to a value from a given column,
provide a list of values to input parameter *queries*. This field can be
populated with column values from any table as long as the type is supported by
the given identifier. See
[Query Identifiers](../../graph_solver/network_graph_solver/#query-identifiers)
for more information.

To return the adjacency list in the response, leave input parameter
*adjacency\_table* empty.

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-query)
before using this endpoint.

## Input Parameter Description

<ParamField body="graph_name" type="string">
  Name of the graph resource to query.
</ParamField>

<ParamField body="queries" type="array of strings">
  Nodes or edges to be queried specified using [query identifiers](../../graph_solver/network_graph_solver/#query-identifiers). Identifiers can be used with existing column names, e.g., 'table.column AS QUERY\_NODE\_ID', raw values, e.g., '\{0, 2} AS QUERY\_NODE\_ID', or expressions, e.g., 'ST\_MAKEPOINT(table.x, table.y) AS QUERY\_NODE\_WKTPOINT'. Multiple values can be provided as long as the same identifier is used for all values. If using raw values in an identifier combination, the number of values specified must match across the combination.
</ParamField>

<ParamField body="restrictions" type="array of strings">
  Additional restrictions to apply to the nodes/edges of an existing graph. Restrictions must be specified using [identifiers](../../graph_solver/network_graph_solver/#identifiers); identifiers are grouped as [combinations](../../graph_solver/network_graph_solver/#id-combos). 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.

  The default value is an empty array ( \[] ).
</ParamField>

<ParamField body="adjacency_table" type="string">
  Name of the table to store the resulting adjacencies, 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). If left blank, the query results are instead returned in the response. If the 'QUERY\_TARGET\_NODE\_LABEL' [query identifier](../../graph_solver/network_graph_solver/#query-identifiers) is used in input parameter *queries*, then two additional columns will be available: 'PATH\_ID' and 'RING\_ID'. See [Using Labels](../../graph_solver/network_graph_solver/#using-labels) for more information.

  The default value is ''.
</ParamField>

<ParamField body="rings" type="int">
  Sets the number of rings around the node to query for adjacency, with '1' being the edges directly attached to the queried node. Also known as number of hops. For example, if it is set to '2', the edge(s) directly attached to the queried node(s) will be returned; in addition, the edge(s) attached to the node(s) attached to the initial ring of edge(s) surrounding the queried node(s) will be returned. If the value is set to '0', any nodes that meet the criteria in input parameter *queries* and input parameter *restrictions* will be returned. This parameter is only applicable when querying nodes.

  The default value is 1.
</ParamField>

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

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

  <Expandable title="options">
    <ParamField body="force_undirected">
      If set to *true*, all inbound edges and outbound edges relative to the node will be returned. If set to *false*, only outbound edges relative to the node will be returned. This parameter is only applicable if the queried graph input parameter *graph\_name* is directed and when querying nodes. Consult [Directed Graphs](../../graph_solver/network_graph_solver/#directed-graphs) for more details.

      The default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="limit">
      When specified (>0), limits the number of query results. The size of the nodes table will be limited by the *limit* value.

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

    <ParamField body="output_wkt_path">
      If true then concatenated wkt line segments will be added as the WKT column of the adjacency table.

      The default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="and_labels">
      If set to *true*, the result of the query has entities that satisfy all of the target labels, instead of any.

      The default value is `false`.

      The supported values are:

      * true
      * false
    </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.
    </ParamField>

    <ParamField body="output_charn_length">
      When specified (>0 and \<=256), limits the number of char length on the output tables for string based nodes. The default length is 64.

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

    <ParamField body="find_common_labels">
      If set to true, for many-to-many queries or multi-level traversals, it lists the common labels between the source and target nodes and edge labels in each path. Otherwise (zero rings), it'll list all labels of the node(s) queried.

      The default value is `false`.

      The supported values are:

      * true
      * false
    </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">
  'query\_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 /query/graph endpoint:

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

    <ResponseField name="adjacency_list_int_array" type="array of longs">
      The adjacency entity integer ID: either edge IDs per node requested (if using QUERY\_EDGE\_ID or QUERY\_NODE1\_ID and QUERY\_NODE2\_ID in the input) or two node IDs per edge requested (if using QUERY\_NODE\_ID in the input).
    </ResponseField>

    <ResponseField name="adjacency_list_string_array" type="array of strings">
      The adjacency entity string ID: either edge IDs per node requested (if using QUERY\_EDGE\_NAME or QUERY\_NODE1\_NAME and QUERY\_NODE2\_NAME in the input) or two node IDs per edge requested (if using QUERY\_NODE\_NAME in the input).
    </ResponseField>

    <ResponseField name="adjacency_list_wkt_array" type="array of strings">
      The adjacency entity WKTPOINT or WKTLINE ID: either edge IDs per node requested (if using QUERY\_EDGE\_WKTLINE or QUERY\_NODE1\_WKTPOINT and QUERY\_NODE2\_WKTPOINT in the input) or two node IDs per edge requested (if using QUERY\_NODE\_WKTPOINT in the input).
    </ResponseField>

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

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