RDCode: Subgraphs.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories

# Subgraphs.h

Go to the documentation of this file.

    00001 //
    00002 //  Copyright (C) 2003-2008 Greg Landrum and Rational Discovery LLC
    00003 //
    00004 //   @@ All Rights Reserved  @@
    00005 //
    00006
    00007 /*! \file Subgraphs.h
    00008
    00009    \brief functionality for finding subgraphs and paths in molecules
    00010
    00011    Difference between _subgraphs_ and _paths_ :
    00012       Subgraphs are potentially branched, whereas paths (in our
    00013       terminology at least) cannot be.  So, the following graph:
    00014 \verbatim
    00015             C--0--C--1--C--3--C
    00016                   |
    00017                   2
    00018                   |
    00019                   C
    00020 \endverbatim
    00021       has 3 _subgraphs_ of length 3: (0,1,2),(0,1,3),(2,1,3)
    00022       but only 2 _paths_ of length 3: (0,1,3),(2,1,3)
    00023 */
    00024 #ifndef _RD_SUBGRAPHS_H_
    00025 #define _RD_SUBGRAPHS_H_
    00026
    00027 #include <vector>
    00028 #include <list>
    00029 #include <map>
    00030
    00031
    00032 namespace RDKit{
    00033   class ROMol;
    00034   // NOTE: before replacing the defn of PATH_TYPE: be aware that
    00035   // we do occasionally use reverse iterators on these things, so
    00036   // replacing with a slist would probably be a bad idea.
    00037   typedef std::vector<int> PATH_TYPE;
    00038   typedef std::list< PATH_TYPE > PATH_LIST;
    00039   typedef PATH_LIST::const_iterator PATH_LIST_CI;
    00040
    00041   typedef std::map<int, PATH_LIST> INT_PATH_LIST_MAP;
    00042   typedef INT_PATH_LIST_MAP::const_iterator INT_PATH_LIST_MAP_CI;
    00043   typedef INT_PATH_LIST_MAP::iterator INT_PATH_LIST_MAP_I;
    00044
    00045   // --- --- --- --- --- --- --- --- --- --- --- --- ---
    00046   //
    00047   //
    00048   // --- --- --- --- --- --- --- --- --- --- --- --- ---
    00049
    00050   //! \brief find all subgraphs in a range of sizes
    00051   /*!
    00052    *   \param mol - the molecule to be considered
    00053    *   \param lowerLen - the minimum subgraph size to find
    00054    *   \param upperLen - the maximum subgraph size to find
    00055    *   \param useHs     - if set, hydrogens in the graph will be considered
    00056    *                      eligible to be in paths. NOTE: this will not add
    00057    *                      Hs to the graph.
    00058   */
    00059   INT_PATH_LIST_MAP findAllSubgraphsOfLengthsMtoN(const ROMol &mol, unsigned int lowerLen,
    00060                                                   unsigned int upperLen, bool useHs=false);
    00061
    00062   //! \brief find all subgraphs of a particular size
    00063   /*!
    00064    *   \param mol - the molecule to be considered
    00065    *   \param targetLen - the length of the subgraphs to be returned
    00066    *   \param useHs     - if set, hydrogens in the graph will be considered
    00067    *                      eligible to be in paths. NOTE: this will not add
    00068    *                      Hs to the graph.
    00069   */
    00070   PATH_LIST findAllSubgraphsOfLengthN(const ROMol &mol,unsigned int targetLen,
    00071                                       bool useHs=false);
    00072
    00073   //! \brief find unique subgraphs of a particular size
    00074   /*!
    00075    *   \param mol - the molecule to be considered
    00076    *   \param targetLen - the length of the subgraphs to be returned
    00077    *   \param useHs     - if set, hydrogens in the graph will be considered
    00078    *                      eligible to be in paths. NOTE: this will not add
    00079    *                      Hs to the graph.
    00080    *   \param useBO     - if set, bond orders will be considered when uniquifying
    00081    *                      the paths
    00082   */
    00083   PATH_LIST findUniqueSubgraphsOfLengthN(const ROMol &mol,unsigned int targetLen,
    00084                                          bool useHs=false,bool useBO=true);
    00085   //! \brief find all paths of a particular size
    00086   /*!
    00087    *   \param mol - the molecule to be considered
    00088    *   \param targetLen - the length of the paths to be returned
    00089    *   \param useBonds  - if set, the path indices will be bond indices,
    00090    *                      not atom indices
    00091    *   \param useHs     - if set, hydrogens in the graph will be considered
    00092    *                      eligible to be in paths. NOTE: this will not add
    00093    *                      Hs to the graph.
    00094   */
    00095   PATH_LIST findAllPathsOfLengthN(const ROMol &mol,unsigned int targetLen,
    00096                                   bool useBonds=true,bool useHs=false);
    00097 }
    00098
    00099
    00100 #endif