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

# create_graph

<div className="kinetica-pydoc">
  <div className="dl py method">
    <div className="dt sig sig-object py" id="gpudb.GPUdb.create_graph"> <span className="sig-name descname"><span className="pre">create\_graph</span></span><span className="sig-paren">(</span><span className="em sig-param"><span className="n"><span className="pre">graph\_name</span></span><span className="o"><span className="pre">=</span></span><span className="default_value"><span className="pre">None</span></span></span>, <span className="em sig-param"><span className="n"><span className="pre">directed\_graph</span></span><span className="o"><span className="pre">=</span></span><span className="default_value"><span className="pre">True</span></span></span>, <span className="em sig-param"><span className="n"><span className="pre">nodes</span></span><span className="o"><span className="pre">=</span></span><span className="default_value"><span className="pre">None</span></span></span>, <span className="em sig-param"><span className="n"><span className="pre">edges</span></span><span className="o"><span className="pre">=</span></span><span className="default_value"><span className="pre">None</span></span></span>, <span className="em sig-param"><span className="n"><span className="pre">weights</span></span><span className="o"><span className="pre">=</span></span><span className="default_value"><span className="pre">None</span></span></span>, <span className="em sig-param"><span className="n"><span className="pre">restrictions</span></span><span className="o"><span className="pre">=</span></span><span className="default_value"><span className="pre">None</span></span></span>, <span className="em sig-param"><span className="n"><span className="pre">options</span></span><span className="o"><span className="pre">=</span></span><span className="default_value"><span className="pre">{"{"}{"}"}</span></span></span><span className="sig-paren">)</span><a href="https://github.com/kineticadb/kinetica-api-python/blob/master/gpudb/gpudb.py#L22566"><span className="viewcode-link"><span className="pre">\[source]</span></span></a></div>

    <div className="dd">
      <p>Creates a new graph network using given nodes, edges, weights, and restrictions.</p>
      <p>IMPORTANT: It’s highly recommended that you review the <a className="reference external" href="/content/graph_solver/network_graph_solver/">Graphs and Solvers</a> concepts documentation, the <a className="reference external" href="/content/guides/graph_rest_guide/">Graph REST Tutorial</a>, and/or some <a className="reference external" href="/content/guides/tags/graph">graph examples</a> before using this endpoint.</p>
      <p><strong>Parameters</strong></p>

      <div className="blockquote">
        <div>
          <div className="dl">
            <div className="dt">graph\_name (<span className="em">str</span>) –</div>

            <div className="dd">
              <p>Name of the graph resource to generate.</p>
            </div>

            <div className="dt">directed\_graph (<span className="em">bool</span>) –</div>

            <div className="dd">
              <p>If set to <span className="em">true</span>, the graph will be directed. If set to <span className="em">false</span>, the graph will not be directed. Consult <a className="reference external" href="/content/graph_solver/network_graph_solver/#directed-graphs">Directed Graphs</a> for more details. Allowed values are:</p>

              <ul className="simple">
                <li>
                  <p>True</p>
                </li>

                <li>
                  <p>False</p>
                </li>
              </ul>

              <p>The default value is True.</p>
            </div>

            <div className="dt">nodes (<span className="em">list of str</span>) –</div>

            <div className="dd">
              <p>Nodes represent fundamental topological units of a graph. Nodes must be specified using <a className="reference external" href="/content/graph_solver/network_graph_solver/#identifiers">identifiers</a>; identifiers are grouped as <a className="reference external" href="/content/graph_solver/network_graph_solver/#id-combos">combinations</a>. 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. The user can provide a single element (which will be automatically promoted to a list internally) or a list.</p>
            </div>

            <div className="dt">edges (<span className="em">list of str</span>) –</div>

            <div className="dd">
              <p>Edges represent the required fundamental topological unit of a graph that typically connect nodes. Edges must be specified using <a className="reference external" href="/content/graph_solver/network_graph_solver/#identifiers">identifiers</a>; identifiers are grouped as <a className="reference external" href="/content/graph_solver/network_graph_solver/#id-combos">combinations</a>. 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. The user can provide a single element (which will be automatically promoted to a list internally) or a list.</p>
            </div>

            <div className="dt">weights (<span className="em">list of str</span>) –</div>

            <div className="dd">
              <p>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 <a className="reference external" href="/content/graph_solver/network_graph_solver/#identifiers">identifiers</a>; identifiers are grouped as <a className="reference external" href="/content/graph_solver/network_graph_solver/#id-combos">combinations</a>. 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. The user can provide a single element (which will be automatically promoted to a list internally) or a list.</p>
            </div>

            <div className="dt">restrictions (<span className="em">list of str</span>) –</div>

            <div className="dd">
              <p>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 <a className="reference external" href="/content/graph_solver/network_graph_solver/#identifiers">identifiers</a>; identifiers are grouped as <a className="reference external" href="/content/graph_solver/network_graph_solver/#id-combos">combinations</a>. 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. The user can provide a single element (which will be automatically promoted to a list internally) or a list.</p>
            </div>

            <div className="dt">options (<span className="em">dict of str to str</span>) –</div>

            <div className="dd">
              <p>Optional parameters. Allowed keys are:</p>

              <ul>
                <li>
                  <p><strong>merge\_tolerance</strong> – 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-5’.</p>
                </li>

                <li>
                  <p><strong>recreate</strong> – If set to <span className="em">true</span> and the graph (using input parameter <span className="em">graph\_name</span>) already exists, the graph is deleted and recreated. Allowed values are:</p>

                  <ul className="simple">
                    <li>
                      <p>true</p>
                    </li>

                    <li>
                      <p>false</p>
                    </li>
                  </ul>

                  <p>The default value is ‘false’.</p>
                </li>

                <li>
                  <p><strong>save\_persist</strong> – If set to <span className="em">true</span>, the graph will be saved in the persist directory (see the <a className="reference external" href="/content/config/#config-main-persistence">config reference</a> for more information). If set to <span className="em">false</span>, the graph will be removed when the graph server is shutdown. Allowed values are:</p>

                  <ul className="simple">
                    <li>
                      <p>true</p>
                    </li>

                    <li>
                      <p>false</p>
                    </li>
                  </ul>

                  <p>The default value is ‘false’.</p>
                </li>

                <li>
                  <p><strong>add\_table\_monitor</strong> – 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 <span className="em">save\_persist</span> is also set to <span className="em">true</span>, the graph will be fully reconstructed and the table monitors will be reattached. For more details on table monitors, see <a className="reference internal" href="#gpudb.GPUdb.create_table_monitor" title="gpudb.GPUdb.create_table_monitor"><code className="xref py py-meth docutils literal notranslate"><span className="pre">GPUdb.create\_table\_monitor()</span></code></a>. Allowed values are:</p>

                  <ul className="simple">
                    <li>
                      <p>true</p>
                    </li>

                    <li>
                      <p>false</p>
                    </li>
                  </ul>

                  <p>The default value is ‘false’.</p>
                </li>

                <li>
                  <p><strong>graph\_table</strong> – If specified, the created graph is also created as a table with the given name, in \[schema\_name.]table\_name format, using standard <a className="reference external" href="/content/concepts/tables/#table-name-resolution">name resolution rules</a> and meeting <a className="reference external" href="/content/concepts/tables/#table-naming-criteria">table naming criteria</a>. The table will have the following identifier columns: ‘EDGE\_ID’, ‘EDGE\_NODE1\_ID’, ‘EDGE\_NODE2\_ID’. If left blank, no table is created. The default value is ‘’.</p>
                </li>

                <li>
                  <p><strong>add\_turns</strong> – 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). Allowed values are:</p>

                  <ul className="simple">
                    <li>
                      <p>true</p>
                    </li>

                    <li>
                      <p>false</p>
                    </li>
                  </ul>

                  <p>The default value is ‘false’.</p>
                </li>

                <li>
                  <p><strong>is\_partitioned</strong> – Allowed values are:</p>

                  <ul className="simple">
                    <li>
                      <p>true</p>
                    </li>

                    <li>
                      <p>false</p>
                    </li>
                  </ul>

                  <p>The default value is ‘false’.</p>
                </li>

                <li>
                  <p><strong>server\_id</strong> – Indicates which graph server(s) to send the request to. Default is to send to the server with the most available memory.</p>
                </li>

                <li>
                  <p><strong>use\_rtree</strong> – Use an range tree structure to accelerate and improve the accuracy of snapping, especially to edges. Allowed values are:</p>

                  <ul className="simple">
                    <li>
                      <p>true</p>
                    </li>

                    <li>
                      <p>false</p>
                    </li>
                  </ul>

                  <p>The default value is ‘true’.</p>
                </li>

                <li>
                  <p><strong>label\_delimiter</strong> – If provided the label string will be split according to this delimiter and each sub-string will be applied as a separate label onto the specified edge. The default value is ‘’.</p>
                </li>

                <li>
                  <p><strong>allow\_multiple\_edges</strong> – Multigraph choice; allowing multiple edges with the same node pairs if set to true, otherwise, new edges with existing same node pairs will not be inserted. Allowed values are:</p>

                  <ul className="simple">
                    <li>
                      <p>true</p>
                    </li>

                    <li>
                      <p>false</p>
                    </li>
                  </ul>

                  <p>The default value is ‘true’.</p>
                </li>

                <li>
                  <p><strong>embedding\_table</strong> – If table exists (should be generated by the match/graph match\_embedding solver), the vector embeddings for the newly inserted nodes will be appended into this table. The default value is ‘’.</p>
                </li>
              </ul>

              <p>The default value is an empty dict ( {"{"}{"}"} ).</p>
            </div>
          </div>
        </div>
      </div>

      <p><strong>Returns</strong></p>

      <div className="blockquote">
        <div>
          <p>A dict with the following entries–</p>

          <div className="dl simple">
            <div className="dt">result (<span className="em">bool</span>) –</div>

            <div className="dd">
              <p>Indicates a successful creation on all servers.</p>
            </div>

            <div className="dt">num\_nodes (<span className="em">long</span>) –</div>

            <div className="dd">
              <p>Total number of nodes created.</p>
            </div>

            <div className="dt">num\_edges (<span className="em">long</span>) –</div>

            <div className="dd">
              <p>Total number of edges created.</p>
            </div>

            <div className="dt">edges\_ids (<span className="em">list of longs</span>) –</div>

            <div className="dd">
              <p>\[Deprecated] Edges given as pairs of node indices. Only populated if export\_create\_results internal option is set to true.</p>
            </div>

            <div className="dt">info (<span className="em">dict of str to str</span>) –</div>

            <div className="dd">
              <p>Additional information.</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
