source: src/Graph/DepthFirstSearchAnalysis.hpp@ aec098

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since aec098 was 49c059, checked in by Frederik Heber <heber@…>, 14 years ago

Moved DepthFirstSearchAnalysis into functor in Graph/.

Smaller fixes:

TESTFIXES:

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/*
2 * DepthFirstSearchAnalysis.hpp
3 *
4 * Created on: Feb 16, 2011
5 * Author: heber
6 */
7
8#ifndef DEPTHFIRSTSEARCHANALYSIS_HPP_
9#define DEPTHFIRSTSEARCHANALYSIS_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <deque>
17
18#include "ConnectedSubgraph.hpp"
19
20class atom;
21class bond;
22class MoleculeLeafClass;
23class molecule;
24
25class DepthFirstSearchAnalysis
26{
27public:
28 /** Constructor of DepthFirstSearchAnalysis.
29 */
30 DepthFirstSearchAnalysis();
31
32 /** Destructor of DepthFirstSearchAnalysis.
33 */
34 ~DepthFirstSearchAnalysis();
35
36 /** Performs a Depth-First search on all atoms.
37 * Marks bonds in molecule as cyclic, bridge, ... and atoms as
38 * articulations points, ...
39 * We use the algorithm from [Even, Graph Algorithms, p.62].
40 * \param *&BackEdgeStack NULL pointer to std::deque<bond *> with all the found back edges, allocated and filled on return
41 * \return list of each disconnected subgraph as an individual molecule class structure
42 */
43 void operator()();
44
45 /** Scans through all bonds and set bond::Cyclic to true where atom::LowpointNr of both ends is equal: LP criterion.
46 * \note Hydrogen bonds can never by cyclic, thus no check for that
47 * \return number of cyclic bonds
48 */
49 unsigned int CyclicBondAnalysis() const;
50
51 /** Removes all molecules and assign anew with known ListOfConnectedSubgraphs.
52 *
53 */
54 void UpdateMoleculeStructure() const;
55
56 /** Creates a chained list of all present molecules.
57 *
58 * \warning returns allocated chained list as reference, has to be free'd item by item through the list
59 *
60 * @return start node of chained molecules list
61 */
62 MoleculeLeafClass *getMoleculeStructure() const;
63
64 /** Picks from a global stack with all back edges the ones in the fragment.
65 *
66 * Reference is the internal BackEdgeStack.
67 *
68 * \param **ListOfLocalAtoms array of father atom::nr to local atom::nr (reverse of atom::father)
69 * \param *LocalStack stack to be filled
70 * \return true - everything ok, false - ReferenceStack was empty
71 */
72 bool PickLocalBackEdges(atom **ListOfLocalAtoms, std::deque<bond *> *&LocalStack) const;
73
74 /** Getter for BackEdgeStack.
75 *
76 * @return const reference to BackEdgeStack
77 */
78 const std::deque<bond *>& getBackEdgeStack() const;
79
80private:
81 /** Resets GraphNodeInfo::ComponentNr and GraphNodeInfo::GraphrNr.
82 *
83 */
84 void Init();
85
86 /** Returns next unused bond for this atom \a *vertex or NULL of none exists.
87 * \param *vertex atom to regard
88 * \return bond class or NULL
89 */
90 bond * FindNextUnused(atom *vertex) const;
91
92 /** Resets bond::Used flag of all bonds in this molecule.
93 * \return true - success, false - -failure
94 */
95 void ResetAllBondsToUnused() const;
96
97 /** Sets the next component number.
98 * This is O(N) as the number of bonds per atom is bound.
99 * \param *vertex atom whose next atom::*ComponentNr is to be set
100 * \param nr number to use
101 */
102 void SetNextComponentNumber(atom *vertex, int nr) const;
103
104 /** Sets atom::GraphNr and atom::LowpointNr to CurrentGraphNr.
105 * \param *Walker current node
106 */
107 void SetWalkersGraphNr(atom *&Walker);
108
109 /** During DFS goes along unvisited bond and touches other atom.
110 * Sets bond::type, if
111 * -# BackEdge: set atom::LowpointNr and push on \a BackEdgeStack
112 * -# TreeEgde: set atom::Ancestor and continue with Walker along this edge
113 * Continue until molecule::FindNextUnused() finds no more unused bonds.
114 * \param *&Walker current node
115 * \param *&Binder current edge
116 */
117 void ProbeAlongUnusedBond(atom *&Walker, bond *&Binder);
118
119 /** Checks whether we have a new component.
120 * if atom::LowpointNr of \a *&Walker is greater than atom::GraphNr of its atom::Ancestor, we have a new component.
121 * Meaning that if we touch upon a node who suddenly has a smaller atom::LowpointNr than its ancestor, then we
122 * have a found a new branch in the graph tree.
123 * \param *&Walker current node
124 * \param &LeafWalker contains reference to destination subgraph
125 */
126 void CheckForaNewComponent(atom *&Walker, ConnectedSubgraph &LeafWalker);
127
128 /** Cleans the root stack when we have found a component.
129 * If we are not BackStepping, then we clear the root stack by putting everything into a
130 * component down till we meet Root.
131 * \param *&Walker current node
132 * \param *&Binder current edge
133 * \param &LeafWalker contains reference to destination subgraph
134 */
135 void CleanRootStackDownTillWalker(atom *&Walker, bond *&Binder, ConnectedSubgraph &LeafWalker);
136
137 /** Output graph information per atom.
138 */
139 void OutputGraphInfoPerAtom() const;
140
141 /** Output graph information per bond.
142 */
143 void OutputGraphInfoPerBond() const;
144
145 std::deque<atom *> AtomStack;
146 std::deque<bond *> BackEdgeStack;
147 int CurrentGraphNr;
148 int ComponentNumber;
149 atom *Root;
150 bool BackStepping;
151
152 typedef std::list< ConnectedSubgraph > ConnectedSubgraphList;
153
154 ConnectedSubgraphList ListOfConnectedSubgraphs;
155};
156
157#endif /* DEPTHFIRSTSEARCHANALYSIS_HPP_ */
Note: See TracBrowser for help on using the repository browser.