.. include:: ../substitutions

.. oe:namespace:: OEChem

.. meta::
   :keywords: OEGetPathLength

.. oe:function:: OEGetPathLength

   .. oe:language:: c++ java csharp

      .. oe:api::

         unsigned int OEGetPathLength(const OEAtomBase* a, const OEAtomBase* b,
                                      unsigned int maxpath = 0)

   .. oe:language:: python

      .. oe:api:: python

         OEGetPathLength(arg1: OEAtomBase, arg2: OEAtomBase, maxPath: int = 0) -> int

   Returns the shortest path length between two atoms i.e. the number of
   bonds between the two given atoms.
   For example, in thiazole ``(c1nccs1)`` the path length between the nitrogen
   and sulfur atom is 2.

   **src, dst**
      The two atoms for which the length of the shortest path returns.
      If the two atoms are the same :ref:`OEAtomBase <OEChem_OEAtomBase>`,
      have different parent molecule or are part of different
      disconnected molecular graphs, the :oe:func:`OEChem::OEGetPathLength`
      function returns zero.

   *maxpath**
      This parameter may be used to specify a maximum path length to
      consider before terminating the search.  If this value is zero, the
      default, there is no upper bound on the returned path length.  Otherwise,
      if the shortest path between the two atoms is greater than **maxpath**
      bonds, this function returns the value zero.

.. seealso::


   * :oe:func:`OEChem::OEShortestPath` function

   .. oe:language:: c++

      * Example program :ref:`minpath.cpp<section_example_oechem_minpath>`

   .. oe:language:: python

      * Example program :ref:`minpath.py<section_example_oechem_minpath>`

   .. oe:language:: java

      * Example program :ref:`MinPath.java<section_example_oechem_minpath>`

   .. oe:language:: csharp

      * Example program :ref:`MinPath.cs<section_example_oechem_minpath>`
