chemaxon.struc
Class CGraph

java.lang.Object
  extended by chemaxon.struc.CGraph
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
MoleculeGraph

public abstract class CGraph
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Chemical graph.

Version:
5.0.4, 05/21/2008
Author:
Peter Csizmadia
See Also:
CNode, CEdge, Serialized Form

Field Summary
protected  int[][] btab
          Bond table.
static int CACHE_REMOVE_ALL
          Cache removal option for clearing all cached info.
static int CACHE_REMOVE_CACHEMEMORY
          Cache removal option for cacheMemory.
protected  java.util.List cacheMemory
           
protected  int[][] cssr
          CSSR ring node indexes.
protected  int[][] ctab
          Connection table.
protected  int edgeCount
          The number of edges.
protected  CEdge[] edges
          The edges (bonds).
protected  int[] fragIds
          Fragment identifiers.
protected  int[] grinv
          Graph invariants.
protected  long grinvCC
          Graph invariant change count.
protected  int grinvOptions
          Options used to last calculate grinv.
protected static int INITIAL_CAPACITY
          Initial capacity of the nodes and edges vectors.
protected  int nFrags
          Number of disconnected fragments.
protected  int nGrinv
          Number of different graph invariants.
protected  int nodeCount
          The number of nodes.
protected  CNode[] nodes
          The nodes (atoms).
protected  CGraph parentGraph
          The structure that contains this graph as a substructure.
static int RMCLEANUP_ALL
          Perform all clean-up methods when removing a node or an edge.
static int RMCLEANUP_EDGES
          When removing a node or an edge, also remove the edge(s) from the node object(s).
protected static int RMCLEANUP_FIXCOMPONENT
          Remove called from RxnMolecule.fixComponent.
static int RMCLEANUP_NONE
          Do not perform any clean-up methods when removing a node or an edge.
protected  int[][] sssr
          SSSR ring node indexes.
protected  int[][] sssr2idx
           
protected  int[] sssrl2idx
           
protected  CGraph superGraph
          Parent of all parents.
 
Constructor Summary
protected CGraph(CGraph p, int n, int e)
          Constructs a fragment with the specified number of nodes and edges
 
Method Summary
 void add(CEdge edge)
          Adds an edge to the graph.
 void add(CNode node)
          Adds a node to the graph.
protected  void addEdge0(CEdge edge)
          Adds an edge.
protected  int addEdgeWithoutChangingIt(CEdge edge)
          Adds an edge without setting its parentGraph and index fields.
protected  void addNode0(CNode node)
          Adds a node.
protected  int addNodeWithoutChangingIt(CNode node)
          Adds a node without setting its parentGraph and index fields.
 void checkConsistency()
          Checks the internal consistency of the structure.
protected  void checkEdgeConsistency()
           
 void clearCachedInfo(int options)
          Deletes the cached information depending on the given options.
abstract  java.lang.Object clone()
          Makes an identical copy of the molecule.
protected  void clonecopy(CGraph graph)
          Copies the clones of nodes and edges of this graph to another one.
protected  boolean clonecopyCGraphWithoutSgroups(int[] cnodes, CEdge[] cedges, int nb, CGraph graph)
          Copies the specified nodes and edges of this graph to another one.
 void clonelesscopy(CGraph graph)
          Copy to selection.
 boolean contains(CEdge edge)
          Checks if the graph contains the specified edge.
 boolean contains(CGraph graph)
          Does the graph contain the specified fragment?
 boolean contains(CNode node)
          Checks if the graph contains the specified node.
 CGraph[] findBasicFrags(java.lang.Class cl)
          Determines the disconnected fragments and puts them into an array.
 int[] findComponentIds()
          Assigns a component ID to each connected component.
 int[] findComponentIds(int[] inds)
          Assigns a component ID to each connected component formed by the specified atom indexes.
protected  int findEdge(CEdge edge)
          Finds an edge in the edgess array.
 void findFrag(int i, CGraph frag)
          Determines the subgraph connected to the specified node.
 void findFragById(int fragId, CGraph frag)
          Determines the subgraph corresponding to the specific fragment ID.
 CGraph[] findFrags(java.lang.Class cl)
          Determines the disconnected fragments and puts them into an array.
protected static int findInArray(java.lang.Object[] array, int[] indices, int n, java.lang.Object o)
          Finds an object in an array.
protected  int findNode(CNode node)
          Finds a node in the nodes array.
 void fuse(CGraph graph)
          Adds those nodes and edges of a graph to this one that are not already elements.
 void fuse(CGraph graph, boolean check)
          Adds nodes and edges of a graph to this one.
protected  void fuse0(CGraph graph)
          Adds those nodes and edges of a graph to this one that are not already elements.
protected  void fuse0(CGraph graph, boolean check)
          Adds nodes and edges of a graph to this one.
 int[][] getBtab()
          Gets the edge (bond) table.
 int[][] getCSSR()
          Gets the Complete Set of Smallest Ring node indexes array.
 int[][] getCtab()
          Gets the connection table.
 CEdge getEdge(int i)
          Gets an edge.
 CEdge[] getEdgeArray()
          Creates an array of edges.
 int getEdgeCount()
          Gets the number of edges.
protected static java.util.List getEdgeList(CNode[] nodes, int na)
          Gets the list of edges for the specified nodes.
 java.util.Vector getEdgeVector()
          Gets the edges.
 CGraph getForefather()
          Gets the first parent.
 int getFragCount()
          Returns the number of fragments.
 int[] getFragIds()
          Gets an array containing the fragment id for each node.
protected  int[] getGrinv()
          Gets the graph invariants array.
 int getGrinv(int[] gi)
          Gets the graph invariants.
 long getGrinvCC()
          Gets the graph invariant change count.
 java.lang.Object getLock()
          Gets the lock object for synchronization.
 CNode getNode(int i)
          Gets a node.
 int getNodeCount()
          Gets the number of nodes.
 java.util.Vector getNodeVector()
          Gets the nodes.
 CGraph getParent()
          Gets the parent graph that contains this substructure.
 int[] getSmallestRingSizeForIdx()
          Get the smallest ring size in which the atom (specified with it's index) can be located.
 int[][] getSSSR()
          Gets the Smallest Set of Smallest Ring node indexes array.
 int[][] getSSSREdges()
          Gets the Smallest Set of Smallest Ring edge indexes array.
 int[][] getSSSRIdxesForAtoms()
          Get the sssr ring indexes in which the atom (specified with it's index) can be located.
protected  void incGrinvCC()
          Increases the graph invariant change count and sets grinv to null.
 void incGrinvCCOnly()
          Increases the graph invariant change count, but does not change grinv.
 int indexOf(CEdge edge)
          Gets the index of the specified edge.
 int indexOf(CNode node)
          Gets the index of the specified node.
 void insertEdge(int i, CEdge edge)
          Inserts the edge at the specified index.
 void insertEdgeInOrder(CEdge e, CEdge[] order)
          Insert an edge in the order specified as the second argument.
 void insertNode(int i, CNode node)
          Inserts the node at the specified index.
protected  void insertNullEdges(int i, int count)
          Insert nulls into the bond array.
protected  void insertNullNodes(int i, int count)
          Insert nulls into the atom array.
 boolean isEmpty()
          Tests whether the graph is empty.
protected  boolean isGrinvCCValid()
          Tests whether the graph invariant change count is valid.
protected  void isolate(CEdge edge)
          Isolates edge: a more efficient way of removing an edge than removeEdge(chemaxon.struc.CEdge), especially for large graphs.
protected  void isolate(CNode node)
          Isolates node: a more efficient way of removing a node than removeNode(chemaxon.struc.CNode), especially for large graphs.
protected  boolean isRealNodeParent()
          Can it be a real node parent?
 boolean isRing()
          Tests whether the graph represents a ring.
 boolean isSimilarTo(CGraph g)
          Checks if the graph is similar to another graph.
 boolean isSymmetric()
          Tests whether the graph is symmetric.
protected  void makeItSimilar(CGraph g)
          Empty method.
protected  int mergeFrags(int fragId1, int fragId2)
          Merges two fragments.
 void mergeNodes(CNode that, CNode a)
          Merges edges of a node with another node, then adds the node to the molecule.
abstract  CGraph newInstance()
          Creates a new CGraph object.
 void pack()
          Reduce memory usage.
protected  void regenCtabs()
          Regenerates connection table and edge table.
 void regenEdges()
          Regenerates the edge vector: remove its elements, then put the edge objects from the nodes into it.
protected  void regenFragIds()
          Searches the disconnected fragments.
 void removeAll()
          Removes all the nodes and edges.
 void removeAllEdges()
          Removes all edges.
 void removeEdge(CEdge edge)
          Removes an edge by reference.
protected  void removeEdge(CEdge edge, int cleanupFlags)
          Removes an edge by reference.
 void removeEdge(int i)
          Removes an edge from the graph.
protected  void removeEdge(int i, int cleanupFlags)
          Removes an edge from the graph.
protected  void removeIsolatedEdges()
          Removes the null edge entries in the edges array and sets the index fields appropriately.
protected  void removeIsolatedNodes()
          Removes the null node entries in the nodes array and sets the index fields appropriately.
 void removeNode(CNode node)
          Removes a node and its edges.
 void removeNode(CNode node, int cleanupFlags)
          Removes a node and its edges with extra clean-up options.
 void removeNode(int i)
          Removes a node and its edges from the graph.
 void removeNode(int i, int cleanupFlags)
          Removes a node and its edges with extra clean-up options.
 void replaceEdge(CEdge olde, CEdge newe)
          Replaces an edge by another one.
protected  void resetCtab()
          An operation performed that changed the connection table and the graph invariants.
protected  void resetGrinvInParents()
          Graph invariants must be recalculated for this graph and all parent graphs.
protected  java.lang.Object[] restoreCache(int n)
          Restores caches like connection table, bond table, etc.
protected  java.lang.Object[] saveCache(int n)
          Saves caches like connection table, bond table, etc.
 void setEdge(int i, CEdge edge)
          Sets the edge at the specified index.
protected  void setGrinvCC(long g)
          Sets the graph invariant change count.
 void setNode(int i, CNode node)
          Sets the node at the specified index.
protected  void setNode0(int i, CNode node)
          Sets the node at the specified index.
 void sortEdgesAccordingTo(CEdge[] order)
          Sorts edges in the same order as they appear in another chemical graph.
 java.lang.String toString()
          Overrides Object.toString() to ease debugging.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INITIAL_CAPACITY

protected static final int INITIAL_CAPACITY
Initial capacity of the nodes and edges vectors.

See Also:
Constant Field Values

RMCLEANUP_NONE

public static final int RMCLEANUP_NONE
Do not perform any clean-up methods when removing a node or an edge.

Since:
Marvin 3.1
See Also:
removeNode(CNode, int), removeNode(int, int), removeEdge(CEdge, int), removeEdge(int, int), Constant Field Values

RMCLEANUP_FIXCOMPONENT

protected static final int RMCLEANUP_FIXCOMPONENT
Remove called from RxnMolecule.fixComponent. For internal use only.

Since:
Marvin 4.1.3, 11/16/2006
See Also:
RMCLEANUP_ALL, Constant Field Values

RMCLEANUP_ALL

public static final int RMCLEANUP_ALL
Perform all clean-up methods when removing a node or an edge.

Since:
Marvin 3.1
See Also:
removeNode(CNode, int), removeNode(int, int), removeEdge(CEdge, int), removeEdge(int, int), Constant Field Values

RMCLEANUP_EDGES

public static final int RMCLEANUP_EDGES
When removing a node or an edge, also remove the edge(s) from the node object(s).

Since:
Marvin 3.1
See Also:
removeNode(CNode, int), removeNode(int, int), removeEdge(CEdge, int), removeEdge(int, int), Constant Field Values

CACHE_REMOVE_ALL

public static final int CACHE_REMOVE_ALL
Cache removal option for clearing all cached info.

See Also:
clearCachedInfo(int), Constant Field Values

CACHE_REMOVE_CACHEMEMORY

public static final int CACHE_REMOVE_CACHEMEMORY
Cache removal option for cacheMemory.

See Also:
cacheMemory, clearCachedInfo(int), Constant Field Values

superGraph

protected transient CGraph superGraph
Parent of all parents.


parentGraph

protected transient CGraph parentGraph
The structure that contains this graph as a substructure.


nodes

protected transient CNode[] nodes
The nodes (atoms).


nodeCount

protected transient int nodeCount
The number of nodes.


edges

protected transient CEdge[] edges
The edges (bonds).


edgeCount

protected transient int edgeCount
The number of edges.


sssr

protected transient int[][] sssr
SSSR ring node indexes.


cssr

protected transient int[][] cssr
CSSR ring node indexes.


ctab

protected transient int[][] ctab
Connection table.


btab

protected transient int[][] btab
Bond table.


fragIds

protected transient int[] fragIds
Fragment identifiers.


nFrags

protected transient int nFrags
Number of disconnected fragments.


grinv

protected transient int[] grinv
Graph invariants. The graph invariants labels each atom - considered as nodes of the molecule graph - with canonical label on the basis of its topology, resulting in classification of constitutionally symmetric nodes.


grinvOptions

protected int grinvOptions
Options used to last calculate grinv.


nGrinv

protected transient int nGrinv
Number of different graph invariants.


grinvCC

protected transient long grinvCC
Graph invariant change count. The number of times the graph invariants may have changed since the creation of the molecule.


cacheMemory

protected transient java.util.List cacheMemory

sssrl2idx

protected transient int[] sssrl2idx

sssr2idx

protected transient int[][] sssr2idx
Constructor Detail

CGraph

protected CGraph(CGraph p,
                 int n,
                 int e)
Constructs a fragment with the specified number of nodes and edges

Parameters:
p - the parent graph or null
n - no reallocation needed until the number of nodes is less than this value
e - no reallocation needed until the number of edges is less than this value
Method Detail

isRealNodeParent

protected boolean isRealNodeParent()
Can it be a real node parent?

Returns:
true
Since:
Marvin 3.0

getNodeVector

public java.util.Vector getNodeVector()
Gets the nodes.

Returns:
a node vector

getEdgeVector

public java.util.Vector getEdgeVector()
Gets the edges.

Returns:
an edge vector

getNodeCount

public int getNodeCount()
Gets the number of nodes.

Returns:
number of nodes

getNode

public CNode getNode(int i)
Gets a node.

Parameters:
i - node index
Returns:
the node object
Since:
Marvin 2.6

setNode

public void setNode(int i,
                    CNode node)
Sets the node at the specified index.

Parameters:
i - node index
node - new node reference
Since:
Marvin 2.9

insertNode

public final void insertNode(int i,
                             CNode node)
Inserts the node at the specified index.

Parameters:
i - node index
node - new node reference
Since:
Marvin 3.4

insertNullNodes

protected void insertNullNodes(int i,
                               int count)
Insert nulls into the atom array.

Parameters:
i - starting index
count - number of new entries
Since:
Marvin 3.4

insertEdge

public final void insertEdge(int i,
                             CEdge edge)
Inserts the edge at the specified index.

Parameters:
i - edge index
edge - new edge reference
Since:
Marvin 3.5.5

insertEdgeInOrder

public void insertEdgeInOrder(CEdge e,
                              CEdge[] order)
Insert an edge in the order specified as the second argument.

Parameters:
e - the edge to insert
order - array of edges defining the order
Since:
Marvin 5.0, 12/07/2007

insertNullEdges

protected void insertNullEdges(int i,
                               int count)
Insert nulls into the bond array.

Parameters:
i - starting index
count - number of new entries
Since:
Marvin 3.5.5

getEdgeCount

public int getEdgeCount()
Gets the number of edges.

Returns:
number of edges

getEdge

public CEdge getEdge(int i)
Gets an edge.

Parameters:
i - edge index
Returns:
the edge object
Since:
Marvin 2.6

setEdge

public void setEdge(int i,
                    CEdge edge)
Sets the edge at the specified index.

Parameters:
i - edge index
edge - the edge reference
Since:
Marvin 2.9

replaceEdge

public void replaceEdge(CEdge olde,
                        CEdge newe)
Replaces an edge by another one.

Parameters:
olde - the old edge
newe - the new edge
Since:
Marvin 4.1, 11/24/2005

add

public void add(CNode node)
Adds a node to the graph.

Parameters:
node - the node object

add

public void add(CEdge edge)
Adds an edge to the graph. If the graph is a superGraph, the edge is also added to its endpoints (two CNode objects).

Parameters:
edge - the edge object

removeNode

public void removeNode(CNode node)
Removes a node and its edges.

Parameters:
node - the node
Since:
Marvin 2.5

removeNode

public void removeNode(int i)
Removes a node and its edges from the graph.

Parameters:
i - the node index
Since:
Marvin 2.5

removeEdge

public void removeEdge(CEdge edge)
Removes an edge by reference.

Parameters:
edge - the edge
Since:
Marvin 2.5

removeEdge

public void removeEdge(int i)
Removes an edge from the graph.

Parameters:
i - the edge index
Since:
Marvin 2.5

removeAllEdges

public void removeAllEdges()
Removes all edges.


removeAll

public void removeAll()
Removes all the nodes and edges.


isolate

protected void isolate(CNode node)
Isolates node: a more efficient way of removing a node than removeNode(chemaxon.struc.CNode), especially for large graphs. Removes the node but instead of shifting the nodes array, simply sets the corresponding entry to null. After isolating some nodes, call removeIsolatedNodes() to get a valid graph.

Parameters:
node - the node
Since:
Marvin 5.0

isolate

protected void isolate(CEdge edge)
Isolates edge: a more efficient way of removing an edge than removeEdge(chemaxon.struc.CEdge), especially for large graphs. Removes the edge but instead of shifting the edges array, simply sets the corresponding entry to null. After isolating some edges, call removeIsolatedEdges() to get a valid graph.

Parameters:
edge - the edge
Since:
Marvin 5.0

removeIsolatedNodes

protected void removeIsolatedNodes()
Removes the null node entries in the nodes array and sets the index fields appropriately. Clean-up method after calling isolate(chemaxon.struc.CNode) for some nodes.

Since:
Marvin 5.0

removeIsolatedEdges

protected void removeIsolatedEdges()
Removes the null edge entries in the edges array and sets the index fields appropriately. Clean-up method after calling isolate(chemaxon.struc.CEdge) for some edges.

Since:
Marvin 5.0

regenEdges

public void regenEdges()
Regenerates the edge vector: remove its elements, then put the edge objects from the nodes into it.


getEdgeList

protected static java.util.List getEdgeList(CNode[] nodes,
                                            int na)
Gets the list of edges for the specified nodes.

Parameters:
nodes - the nodes
na - the number of nodes
Returns:
the list of nodes
Since:
Marvin 5.0.1, 02/05/2008

getEdgeArray

public CEdge[] getEdgeArray()
Creates an array of edges.

Returns:
array of edge objects
Since:
Marvin 3.5, 09/02/2004

sortEdgesAccordingTo

public void sortEdgesAccordingTo(CEdge[] order)
Sorts edges in the same order as they appear in another chemical graph.

Parameters:
order - the edges in the other graph
Since:
Marvin 3.5, 09/02/2004

indexOf

public int indexOf(CNode node)
Gets the index of the specified node.

Parameters:
node - the node
Returns:
the index, or -1 if not found
Since:
Marvin 2.7

indexOf

public int indexOf(CEdge edge)
Gets the index of the specified edge.

Parameters:
edge - the edge
Returns:
the index, or -1 if not found
Since:
Marvin 2.7

contains

public boolean contains(CNode node)
Checks if the graph contains the specified node.

Parameters:
node - the node object
Returns:
true if the graph contains the object, false otherwise

contains

public boolean contains(CEdge edge)
Checks if the graph contains the specified edge.

Parameters:
edge - the edge object
Returns:
true if the graph contains the object, false otherwise

isEmpty

public boolean isEmpty()
Tests whether the graph is empty.

Returns:
true if the graph does not contain any nodes or edges, false otherwise

isSimilarTo

public boolean isSimilarTo(CGraph g)
Checks if the graph is similar to another graph. Two graphs are similar if
  1. they have the same number of nodes and edges,
  2. for each node ai in the first graph, there is a corresponding node aj in the other graph, with the same graph invariant, "equal properties" and "similar edges".

Returns:
true if the graphs are similar, false otherwise
Since:
Marvin 3.4.1, 07/21/2004
See Also:
CNode.haveEqualProperties(CNode), CNode.haveSimilarEdges(CNode)

isRing

public boolean isRing()
Tests whether the graph represents a ring.

Returns:
true if the graph is a ring, false otherwise
Since:
Marvin 4.1, 01/27/2006

isSymmetric

public boolean isSymmetric()
Tests whether the graph is symmetric. The graph is symmetric if each node has the same graph invariant value.

Returns:
true if the graph is a symmetric, false otherwise
Since:
Marvin 4.1, 01/27/2006

removeNode

public void removeNode(CNode node,
                       int cleanupFlags)
Removes a node and its edges with extra clean-up options. This method is for internal use only. Use removeNode(CNode) instead unless you are sure what you are doing.

Parameters:
node - the node
cleanupFlags - extra clean-up methods
Since:
Marvin 3.1
See Also:
RMCLEANUP_NONE, RMCLEANUP_ALL, RMCLEANUP_EDGES

removeNode

public void removeNode(int i,
                       int cleanupFlags)
Removes a node and its edges with extra clean-up options. This method is for internal use only. Use removeNode(int) instead unless you are sure what you are doing.

Parameters:
i - the node index
cleanupFlags - extra clean-up methods
Since:
Marvin 3.1
See Also:
RMCLEANUP_NONE, RMCLEANUP_ALL, RMCLEANUP_EDGES

removeEdge

protected void removeEdge(CEdge edge,
                          int cleanupFlags)
Removes an edge by reference.

Parameters:
edge - the edge
cleanupFlags - extra clean-up methods
Since:
Marvin 3.1
See Also:
RMCLEANUP_NONE, RMCLEANUP_ALL, RMCLEANUP_EDGES

removeEdge

protected void removeEdge(int i,
                          int cleanupFlags)
Removes an edge from the graph.

Parameters:
i - the edge index
cleanupFlags - extra clean-up methods
Since:
Marvin 3.1
See Also:
RMCLEANUP_NONE, RMCLEANUP_ALL, RMCLEANUP_EDGES

fuse0

protected final void fuse0(CGraph graph)
Adds those nodes and edges of a graph to this one that are not already elements. Made final in Marvin 5.0. From Marvin 5.0, subclasses should implement fuse0(chemaxon.struc.CGraph, boolean) instead.

Parameters:
graph - the graph

fuse0

protected void fuse0(CGraph graph,
                     boolean check)
Adds nodes and edges of a graph to this one.

Parameters:
graph - the graph
check - true if a containment check should be performed to ensure that only those nodes and edges are added that are not already elements - false if the graph is known to be disjoint from this graph and this check can be safely skipped
Since:
Marvin 5.0

fuse

public final void fuse(CGraph graph)
Adds those nodes and edges of a graph to this one that are not already elements. Made final in Marvin 5.0. From Marvin 5.0, subclasses should implement fuse(chemaxon.struc.CGraph, boolean) instead.

Parameters:
graph - the other graph

fuse

public void fuse(CGraph graph,
                 boolean check)
Adds nodes and edges of a graph to this one.

Parameters:
graph - the graph
check - true if a containment check should be performed to ensure that only those nodes and edges are added that are not already elements - false if the graph is known to be disjoint from this graph and this check can be safely skipped
Since:
Marvin 5.0

mergeNodes

public void mergeNodes(CNode that,
                       CNode a)
Merges edges of a node with another node, then adds the node to the molecule.

Parameters:
that - the node
a - the other node

contains

public boolean contains(CGraph graph)
Does the graph contain the specified fragment?

Parameters:
graph - the fragment
Returns:
true if it contains the graph, false if not

clonecopy

protected void clonecopy(CGraph graph)
Copies the clones of nodes and edges of this graph to another one.

Parameters:
graph - the target graph

clonecopyCGraphWithoutSgroups

protected boolean clonecopyCGraphWithoutSgroups(int[] cnodes,
                                                CEdge[] cedges,
                                                int nb,
                                                CGraph graph)
Copies the specified nodes and edges of this graph to another one. S-groups are not copied.

Parameters:
cnodes - array of node indices to copy or null
cedges - array of edges to copy or null to copy edges in cnodes only
nb - number of edges
graph - the target graph
Returns:
false if the nodes array contains all edge end points, true if there is at least one external bond
Since:
Marvin 5.0.2, 03/07/2008

clonelesscopy

public void clonelesscopy(CGraph graph)
Copy to selection. Copies without cloning.

Parameters:
graph - the target graph (the selection)

clone

public abstract java.lang.Object clone()
Makes an identical copy of the molecule. The new molecule will not be subgraph of the parentGraph of the original one. It will be its own superGraph.

Overrides:
clone in class java.lang.Object
Returns:
the clone

toString

public java.lang.String toString()
Overrides Object.toString() to ease debugging. Returns a string consisting of the classname (without the package name!), the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. If the graph is not empty, then the string also contains the number of nodes and edges in "[Na,Mb]" form.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object

getSSSR

public final int[][] getSSSR()
Gets the Smallest Set of Smallest Ring node indexes array. If the SSSR array is not calculated for the molecule, then create it. sssr[i][j] is the j-th node index at the i-th SSSR ring in the molecule. This array is cached, so clone it if you plan to modify it.

Returns:
the sssr node index arrays
Since:
Marvin 3.0

getCSSR

public final int[][] getCSSR()
Gets the Complete Set of Smallest Ring node indexes array. CSSR is generated by adding the ring to CSSR which are xor of the SSSR but size smaller then 14 and also size not larger then the largest ring in the SSSR. If the CSSR array is not calculated for the molecule, then create it. cssr[i][j] is the j-th node index at the i-th CSSR ring in the molecule. This array is cached, so clone it if you plan to modify it.

Returns:
the cssr node index arrays
Since:
Marvin 5.0

getSSSREdges

public final int[][] getSSSREdges()
Gets the Smallest Set of Smallest Ring edge indexes array. Values are recalculated each time.

Returns:
the sssr edge index arrays
Since:
Marvin 5.1.2

getCtab

public int[][] getCtab()
Gets the connection table. If there is no connection table for the graph, then creates it. ctab[i][j] will be the index of the jth neighbor of the ith node. This array is cached, so clone it if you plan to modify it.

Returns:
the ctab array
Since:
Marvin 2.6

getBtab

public int[][] getBtab()
Gets the edge (bond) table. If there is no edge table for the molecule, then create it. btab[i][j] will be the index of the edge between nodes i and j, or -1 if there is no edge. This array is cached, so clone it if you plan to modify it.

Returns:
the btab array
Since:
Marvin 2.6

getGrinv

public int getGrinv(int[] gi)
Gets the graph invariants.

Parameters:
gi - the output array
Returns:
zero

getGrinv

protected int[] getGrinv()
Gets the graph invariants array. This array is cached, so clone it if you plan to modify it.

Returns:
the grinv field
Since:
Marvin 3.0

getGrinvCC

public final long getGrinvCC()
Gets the graph invariant change count. Returns the number of times the graph invariants may have changed since the creation of the molecule.

Returns:
graph invariant change count

setGrinvCC

protected final void setGrinvCC(long g)
Sets the graph invariant change count.

Parameters:
g - graph invariant change count
Since:
Marvin 3.4

incGrinvCC

protected final void incGrinvCC()
Increases the graph invariant change count and sets grinv to null.

Since:
Marvin 3.5

incGrinvCCOnly

public final void incGrinvCCOnly()
Increases the graph invariant change count, but does not change grinv. Handle with care, it may force certain data to be recalculated!

Since:
Marvin 4.0 5/07/2005

resetGrinvInParents

protected final void resetGrinvInParents()
Graph invariants must be recalculated for this graph and all parent graphs.


findComponentIds

public final int[] findComponentIds()
Assigns a component ID to each connected component.

Returns:
the component ID array (the i-th ID is the component ID for node i)
Since:
Marvin 4.0

findComponentIds

public final int[] findComponentIds(int[] inds)
Assigns a component ID to each connected component formed by the specified atom indexes.

Parameters:
inds - node index array, null means all nodes
Returns:
the corresponding component ID array (the i-th ID is the component ID for node inds[i] or node i if the node index array is null)
Since:
Marvin 4.0

getFragCount

public final int getFragCount()
Returns the number of fragments.

Returns:
the number of fragments
Since:
Marvin 3.01

getFragIds

public final int[] getFragIds()
Gets an array containing the fragment id for each node. This array is cached, so clone it if you plan to modify it.

Returns:
array of fragment identifiers
Since:
Marvin 2.6

findBasicFrags

public final CGraph[] findBasicFrags(java.lang.Class cl)
Determines the disconnected fragments and puts them into an array. Atoms are removed from the original molecule object unless the fragment class is SelectionMolecule.class. The original node order is preserved in the returned fragments. Fragment order is also determined by the original node order. The first fragment is the one containing node 0, the second fragment is the one containing the smallest indexed node not in the first fragment, etc. This method provides the basic fragmentation that relies on classical graph theory and is not overwritten by successor. DO NOT USE WITH OTHER FRAGMENTATION RELATED METHODS!

Parameters:
cl - create fragment objects of this class
Returns:
array of fragments
Since:
Marvin 5.0

findFrags

public CGraph[] findFrags(java.lang.Class cl)
Determines the disconnected fragments and puts them into an array. Atoms are removed from the original molecule object unless the fragment class is SelectionMolecule.class. The original node order is preserved in the returned fragments. Fragment order is also determined by the original node order. The first fragment is the one containing node 0, the second fragment is the one containing the smallest indexed node not in the first fragment, etc.

Parameters:
cl - create fragment objects of this class
Returns:
array of fragments
Since:
Marvin 3.0

findFrag

public final void findFrag(int i,
                           CGraph frag)
Determines the subgraph connected to the specified node. Subsequent calls with different node (i) argument are possible because only those nodes and edges are added that are still not elements of frag. Nodes are removed from the original graph object unless the frag is a SelectionMolecule.

Parameters:
i - node index
frag - add the nodes and edges to this CGraph
Since:
Marvin 2.6

findFragById

public final void findFragById(int fragId,
                               CGraph frag)
Determines the subgraph corresponding to the specific fragment ID. Nodes are removed from the original graph object unless the frag is a SelectionMolecule.

Parameters:
fragId - fragment ID
frag - add the nodes and edges to this CGraph
Since:
Marvin 4.0
See Also:
getFragIds()

getLock

public final java.lang.Object getLock()
Gets the lock object for synchronization. The lock object is the top parent.

Returns:
the lock object
Since:
Marvin 2.6

getParent

public final CGraph getParent()
Gets the parent graph that contains this substructure.

Returns:
the parent, or null if this is the supergraph
Since:
Marvin 2.6

getForefather

public final CGraph getForefather()
Gets the first parent.

Returns:
parent of all parents
Since:
Marvin 2.9.11

pack

public void pack()
Reduce memory usage.


newInstance

public abstract CGraph newInstance()
Creates a new CGraph object.

Returns:
new CGraph object

makeItSimilar

protected void makeItSimilar(CGraph g)
Empty method.

Parameters:
g - a CGraph object

resetCtab

protected void resetCtab()
An operation performed that changed the connection table and the graph invariants.

Since:
Marvin 2.6

findNode

protected final int findNode(CNode node)
Finds a node in the nodes array.

Returns:
the node index or -1 if not found

findEdge

protected final int findEdge(CEdge edge)
Finds an edge in the edgess array.

Returns:
the edge index or -1 if not found

regenCtabs

protected void regenCtabs()
Regenerates connection table and edge table.

Since:
Marvin 2.6

regenFragIds

protected void regenFragIds()
Searches the disconnected fragments. Fragment order is determined by the node order. The first fragment is the one containing node 0, the second fragment is the one containing the smallest indexed node not in the first fragment, etc. This method can be overwritten by successors to provide additional fragmentation behavior.

Since:
Marvin 5.0

mergeFrags

protected final int mergeFrags(int fragId1,
                               int fragId2)
Merges two fragments.

Parameters:
fragId1 - first fragment
fragId2 - second fragment
Returns:
the new fragment ID of the merged fragments.
Since:
Marvin 5.0

addNode0

protected void addNode0(CNode node)
Adds a node.

Parameters:
node - the node reference

addNodeWithoutChangingIt

protected final int addNodeWithoutChangingIt(CNode node)
Adds a node without setting its parentGraph and index fields.

Parameters:
node - the node reference
Returns:
the new node index

setNode0

protected void setNode0(int i,
                        CNode node)
Sets the node at the specified index.

Parameters:
i - node index
node - new node reference
Since:
Marvin 2.10.5

addEdge0

protected void addEdge0(CEdge edge)
Adds an edge.

Parameters:
edge - the edge reference

addEdgeWithoutChangingIt

protected final int addEdgeWithoutChangingIt(CEdge edge)
Adds an edge without setting its parentGraph and index fields.

Parameters:
edge - the edge reference
Returns:
the new edge index

saveCache

protected java.lang.Object[] saveCache(int n)
Saves caches like connection table, bond table, etc.

Since:
Marvin 3.4

restoreCache

protected java.lang.Object[] restoreCache(int n)
Restores caches like connection table, bond table, etc.

Since:
Marvin 3.4

checkConsistency

public void checkConsistency()
Checks the internal consistency of the structure. Use this method for debugging.

Throws:
java.lang.RuntimeException - if inconsistency found
Since:
Marvin 5.0, 11/06/2007

checkEdgeConsistency

protected void checkEdgeConsistency()

findInArray

protected static final int findInArray(java.lang.Object[] array,
                                       int[] indices,
                                       int n,
                                       java.lang.Object o)
Finds an object in an array.

Parameters:
array - the array
indices - array indices or null
n - the number of elements
Returns:
the object index or -1 if not found
Since:
Marvin 5.0.2, 03/07/2008

clearCachedInfo

public void clearCachedInfo(int options)
Deletes the cached information depending on the given options. For the sake of simplicity option '0' clears all cache info.

Parameters:
options - options for the cache clearing
Since:
Marvin 4.0.2 09/20/2005
See Also:
CACHE_REMOVE_ALL, CACHE_REMOVE_CACHEMEMORY

getSmallestRingSizeForIdx

public int[] getSmallestRingSizeForIdx()
Get the smallest ring size in which the atom (specified with it's index) can be located. This array is cached, so clone it if you plan to modify it.

Returns:
smallest ring size for each atom index.
Since:
Marvin 4.1 4/13/2006

getSSSRIdxesForAtoms

public int[][] getSSSRIdxesForAtoms()
Get the sssr ring indexes in which the atom (specified with it's index) can be located. This array is cached, so clone it if you plan to modify it.

Returns:
sssr ring indexes for each atom index.
Since:
Marvin 4.1.8 4/17/2007

isGrinvCCValid

protected boolean isGrinvCCValid()
Tests whether the graph invariant change count is valid.

Returns:
true
Since:
Marvin 5.0, 11/30/2007