Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG
Boolean with which debugging can be turned on.
|
Constructor and Description |
---|
PathTools() |
Modifier and Type | Method and Description |
---|---|
static void |
breadthFirstSearch(IAtomContainer atomContainer,
List<IAtom> sphere,
IAtomContainer molecule)
Performs a breadthFirstSearch in an AtomContainer starting with a
particular sphere, which usually consists of one start atom.
|
static void |
breadthFirstSearch(IAtomContainer atomContainer,
List<IAtom> sphere,
IAtomContainer molecule,
int max)
Performs a breadthFirstSearch in an AtomContainer starting with a
particular sphere, which usually consists of one start atom.
|
static int |
breadthFirstTargetSearch(IAtomContainer atomContainer,
List<IAtom> sphere,
IAtom target,
int pathLength,
int cutOff)
Performs a breadthFirstTargetSearch in an AtomContainer starting with a
particular sphere, which usually consists of one start atom.
|
static int[][] |
computeFloydAPSP(double[][] costMatrix)
All-Pairs-Shortest-Path computation based on Floyd's
algorithm (Floyd, R.W.. Commun. ACM. 1962. 5).
|
static int[][] |
computeFloydAPSP(int[][] costMatrix)
All-Pairs-Shortest-Path computation based on Floyd's
algorithm (Floyd, R.W.. Commun. ACM. 1962. 5).
|
static boolean |
depthFirstTargetSearch(IAtomContainer molecule,
IAtom root,
IAtom target,
IAtomContainer path)
Recursively performs a depth first search in a molecular graphs contained in
the AtomContainer molecule, starting at the root atom and returning when it
hits the target atom.
|
static IAtom[] |
findClosestByBond(IAtomContainer atomContainer,
IAtom atom,
int max)
Returns the atoms which are closest to an atom in an AtomContainer by bonds.
|
static List<List<IAtom>> |
getAllPaths(IAtomContainer atomContainer,
IAtom start,
IAtom end)
Get a list of all the paths between two atoms.
|
static int[] |
getInt2DColumnSum(int[][] apsp)
Sums up the columns in a 2D int matrix.
|
static List<List<IAtom>> |
getLimitedPathsOfLengthUpto(IAtomContainer atomContainer,
IAtom start,
int length,
int limit)
Get all the paths starting from an atom of length 0 up to the specified
length.
|
static int |
getMolecularGraphDiameter(IAtomContainer atomContainer)
Returns the diameter of the molecular graph.
|
static int |
getMolecularGraphRadius(IAtomContainer atomContainer)
Returns the radius of the molecular graph.
|
static List<List<IAtom>> |
getPathsOfLength(IAtomContainer atomContainer,
IAtom start,
int length)
Get the paths starting from an atom of specified length.
|
static List<List<IAtom>> |
getPathsOfLengthUpto(IAtomContainer atomContainer,
IAtom start,
int length)
Get all the paths starting from an atom of length 0 upto the specified length.
|
static List<IAtom> |
getShortestPath(IAtomContainer atomContainer,
IAtom start,
IAtom end)
Deprecated.
This implementation recalculates all shortest paths from the start atom
for each method call and does not indicate if there are equally short paths
from the start to the end. Replaced by
ShortestPaths.atomsTo(IAtom) |
static int |
getVertexCountAtDistance(IAtomContainer atomContainer,
int distance)
Returns the number of vertices that are a distance 'd' apart.
|
protected static void |
resetFlags(IAtomContainer atomContainer) |
public static final boolean DEBUG
public static int[] getInt2DColumnSum(int[][] apsp)
apsp
- The 2D int matrixpublic static int[][] computeFloydAPSP(int[][] costMatrix)
costMatrix
- edge cost matrixpublic static int[][] computeFloydAPSP(double[][] costMatrix)
costMatrix
- edge cost matrixpublic static boolean depthFirstTargetSearch(IAtomContainer molecule, IAtom root, IAtom target, IAtomContainer path)
CAUTION: This recursive method sets the VISITED flag of each atom does not reset it after finishing the search. If you want to do the operation on the same collection of atoms more than once, you have to set all the VISITED flags to false before each operation by looping of the atoms and doing a "atom.setFlag((CDKConstants.VISITED, false));"
Note that the path generated by the search will not contain the root atom, but will contain the target atom
molecule
- The AtomContainer to be searchedroot
- The root atom to start the search attarget
- The targetpath
- An AtomContainer to be filled with the pathpublic static void breadthFirstSearch(IAtomContainer atomContainer, List<IAtom> sphere, IAtomContainer molecule)
atomContainer
- The AtomContainer to be searchedsphere
- A sphere of atoms to start the search withmolecule
- A molecule into which all the atoms and bonds are stored
that are found during searchpublic static IAtom[] findClosestByBond(IAtomContainer atomContainer, IAtom atom, int max)
atomContainer
- The AtomContainer to examineatom
- the atom to start frommax
- the number of neighbours to returnpublic static void breadthFirstSearch(IAtomContainer atomContainer, List<IAtom> sphere, IAtomContainer molecule, int max)
IMPORTANT: this method does not reset the VISITED flags, which must be done if calling this method twice!
atomContainer
- The AtomContainer to be searchedsphere
- A sphere of atoms to start the search withmolecule
- A molecule into which all the atoms and bonds are stored
that are found during searchmax
- public static int breadthFirstTargetSearch(IAtomContainer atomContainer, List<IAtom> sphere, IAtom target, int pathLength, int cutOff)
atomContainer
- The AtomContainer in which the path search is to be performed.sphere
- The sphere of atoms to start with. Usually just the starting atomtarget
- The target atom to be searchedpathLength
- The current path length, incremented and passed in recursive calls. Call this method with "zero".cutOff
- Stop the path search when this cutOff sphere count has been reatomContainerhedprotected static void resetFlags(IAtomContainer atomContainer)
public static int getMolecularGraphRadius(IAtomContainer atomContainer)
atomContainer
- The molecule to considerpublic static int getMolecularGraphDiameter(IAtomContainer atomContainer)
atomContainer
- The molecule to considerpublic static int getVertexCountAtDistance(IAtomContainer atomContainer, int distance)
atomContainer
- The molecule to considerdistance
- The distance to consider@Deprecated public static List<IAtom> getShortestPath(IAtomContainer atomContainer, IAtom start, IAtom end)
ShortestPaths.atomsTo(IAtom)
atomContainer
- The molecule to search instart
- The starting atomend
- The ending atomList
containing the atoms in the shortest path between start
and
end
inclusiveShortestPaths
,
ShortestPaths.atomsTo(IAtom)
,
AllPairsShortestPaths
public static List<List<IAtom>> getAllPaths(IAtomContainer atomContainer, IAtom start, IAtom end)
atomContainer
- The molecule to considerstart
- The starting Atom of the pathend
- The ending Atom of the pathList
containing all the paths between the specified atomspublic static List<List<IAtom>> getPathsOfLength(IAtomContainer atomContainer, IAtom start, int length)
List
of atoms that
make up the path (ie they are sequentially connected).atomContainer
- The molecule to considerstart
- The starting atomlength
- The length of paths to look forList
containing the paths foundpublic static List<List<IAtom>> getPathsOfLengthUpto(IAtomContainer atomContainer, IAtom start, int length)
List
of atoms that
make up the path (ie they are sequentially connected).atomContainer
- The molecule to considerstart
- The starting atomlength
- The maximum length of paths to look forList
containing the paths foundpublic static List<List<IAtom>> getLimitedPathsOfLengthUpto(IAtomContainer atomContainer, IAtom start, int length, int limit) throws CDKException
limit
then an
exception is thrown. This method returns a set of paths. Each path
is a List
of atoms that make up the path (ie they are
sequentially connected).atomContainer
- The molecule to considerstart
- The starting atomlength
- The maximum length of paths to look forlimit
- Limit the number of paths - thrown an exception if
exceededList
containing the paths foundCDKException
- throw if the number of paths generated was larger
than the limit.Copyright © 2021. All rights reserved.