Index: src/Graph/BuildInducedSubgraph.cpp
===================================================================
--- src/Graph/BuildInducedSubgraph.cpp	(revision 2d4334de0df04fbf9bf9d9b86cdd57638d71e072)
+++ src/Graph/BuildInducedSubgraph.cpp	(revision 2d4334de0df04fbf9bf9d9b86cdd57638d71e072)
@@ -0,0 +1,91 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * BuildInducedSubgraph.cpp
+ *
+ *  Created on: Mar 3, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "BuildInducedSubgraph.hpp"
+
+#include "atom.hpp"
+#include "Bond/bond.hpp"
+#include "molecule.hpp"
+#include "CodePatterns/Assert.hpp"
+#include "CodePatterns/Log.hpp"
+#include "CodePatterns/Verbose.hpp"
+
+
+BuildInducedSubgraph::BuildInducedSubgraph(molecule * const _Son, const molecule * const _Father) :
+  Son(_Son),
+  Father(_Father)
+{
+  // reset parent list
+  ParentList.clear();
+}
+
+BuildInducedSubgraph::~BuildInducedSubgraph()
+{}
+
+
+void BuildInducedSubgraph::FillParentList()
+{
+  // fill parent list with sons
+  DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl);
+  for (molecule::const_iterator iter = Son->begin(); iter != Son->end(); ++iter) {
+    ParentList[(*iter)->father] = (*iter);
+    // Outputting List for debugging
+    LOG(4, "INFO: ParentList[] of " << (*iter)->father << " is " << *ParentList[(*iter)->father] << ".");
+  }
+}
+
+bool BuildInducedSubgraph::CreateBondsFromParent()
+{
+  bool status = true;
+  atom *OtherAtom = NULL;
+  // check each entry of parent list and if ok (one-to-and-onto matching) create bonds
+  LOG(2, "STATUS: Creating bonds.");
+  for (molecule::const_iterator iter = Father->begin(); iter != Father->end(); ++iter) {
+    if (ParentList.count(*iter)) {
+      if (ParentList[(*iter)]->father != (*iter)) {
+        status = false;
+      } else {
+        const BondList& ListOfBonds = (*iter)->getListOfBonds();
+        for (BondList::const_iterator Runner = ListOfBonds.begin();
+            Runner != ListOfBonds.end();
+            ++Runner) {
+          OtherAtom = (*Runner)->GetOtherAtom((*iter));
+          if (ParentList.count(OtherAtom)) { // if otheratom is also a father of an atom on this molecule, create the bond
+            LOG(4, "INFO: Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[(*iter)]->getName() << " and " << ParentList[OtherAtom]->getName() << ".");
+            Son->AddBond(ParentList[(*iter)], ParentList[OtherAtom], (*Runner)->BondDegree);
+          }
+        }
+      }
+    }
+  }
+  return status;
+}
+
+
+bool BuildInducedSubgraph::operator()(){
+  bool status = true;
+
+  FillParentList();
+  status = CreateBondsFromParent();
+
+  return status;
+}
+
Index: src/Graph/BuildInducedSubgraph.hpp
===================================================================
--- src/Graph/BuildInducedSubgraph.hpp	(revision 2d4334de0df04fbf9bf9d9b86cdd57638d71e072)
+++ src/Graph/BuildInducedSubgraph.hpp	(revision 2d4334de0df04fbf9bf9d9b86cdd57638d71e072)
@@ -0,0 +1,47 @@
+/*
+ * BuildInducedSubgraph.hpp
+ *
+ *  Created on: Mar 3, 2011
+ *      Author: heber
+ */
+
+#ifndef BUILDINDUCEDSUBGRAPH_HPP_
+#define BUILDINDUCEDSUBGRAPH_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <map>
+
+class atom;
+class molecule;
+
+class BuildInducedSubgraph
+{
+public:
+  BuildInducedSubgraph(molecule * const _Son, const molecule * const _Father);
+  ~BuildInducedSubgraph();
+
+  /** Adds bond structure to this molecule from \a Father molecule.
+   * This basically causes this molecule to become an induced subgraph of the \a Father, i.e. for every bond in Father
+   * with end points present in this molecule, bond is created in this molecule.
+   * Special care was taken to ensure that this is of complexity O(N), where N is the \a Father's molecule::AtomCount.
+   * \param *Father father molecule
+   * \return true - is induced subgraph, false - there are atoms with fathers not in \a Father
+   * \todo not checked, not fully working probably
+   */
+  bool operator()();
+
+
+private:
+  std::map<atom *, atom*> ParentList;
+  molecule * const Son;
+  const molecule * const Father;
+
+  void FillParentList();
+  bool CreateBondsFromParent();
+};
+
+#endif /* BUILDINDUCEDSUBGRAPH_HPP_ */
Index: src/Graph/Makefile.am
===================================================================
--- src/Graph/Makefile.am	(revision dda246d334045cb752f130960f92fe011e0d85b8)
+++ src/Graph/Makefile.am	(revision 2d4334de0df04fbf9bf9d9b86cdd57638d71e072)
@@ -9,4 +9,5 @@
 GRAPHSOURCE = \
 	BreadthFirstSearchAdd.cpp \
+	BuildInducedSubgraph.cpp \
 	ConnectedSubgraph.cpp \
 	CyclicStructureAnalysis.cpp \
@@ -15,4 +16,5 @@
 GRAPHHEADER = \
 	BreadthFirstSearchAdd.hpp \
+	BuildInducedSubgraph.hpp \
 	ConnectedSubgraph.hpp \
 	CyclicStructureAnalysis.hpp \
Index: src/molecule.hpp
===================================================================
--- src/molecule.hpp	(revision dda246d334045cb752f130960f92fe011e0d85b8)
+++ src/molecule.hpp	(revision 2d4334de0df04fbf9bf9d9b86cdd57638d71e072)
@@ -226,5 +226,4 @@
   void FragmentBOSSANOVA(Graph *&FragmentList, KeyStack &RootStack);
   int PowerSetGenerator(int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet);
-  bool BuildInducedSubgraph(const molecule *Father);
   molecule * StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem);
   void SPFragmentGenerator(struct UniqueFragments *FragmentSearch, int RootDistance, std::vector<bond *> &BondsSet, int SetDimension, int SubOrder);
Index: src/molecule_graph.cpp
===================================================================
--- src/molecule_graph.cpp	(revision dda246d334045cb752f130960f92fe011e0d85b8)
+++ src/molecule_graph.cpp	(revision 2d4334de0df04fbf9bf9d9b86cdd57638d71e072)
@@ -327,80 +327,4 @@
 ;
 
-void BuildInducedSubgraph_Init(atom **&ParentList, int AtomCount)
-{
-  // reset parent list
-  ParentList = new atom*[AtomCount];
-  for (int i=0;i<AtomCount;i++)
-    ParentList[i] = NULL;
-  DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl);
-}
-;
-
-void BuildInducedSubgraph_FillParentList(const molecule *mol, const molecule *Father, atom **&ParentList)
-{
-  // fill parent list with sons
-  DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl);
-  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
-    ParentList[(*iter)->father->getNr()] = (*iter);
-    // Outputting List for debugging
-    DoLog(4) && (Log() << Verbose(4) << "Son[" << (*iter)->father->getNr() << "] of " << (*iter)->father << " is " << ParentList[(*iter)->father->getNr()] << "." << endl);
-  }
-};
-
-void BuildInducedSubgraph_Finalize(atom **&ParentList)
-{
-  delete[](ParentList);
-}
-;
-
-bool BuildInducedSubgraph_CreateBondsFromParent(molecule *mol, const molecule *Father, atom **&ParentList)
-{
-  bool status = true;
-  atom *OtherAtom = NULL;
-  // check each entry of parent list and if ok (one-to-and-onto matching) create bonds
-  DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl);
-  for (molecule::const_iterator iter = Father->begin(); iter != Father->end(); ++iter) {
-    if (ParentList[(*iter)->getNr()] != NULL) {
-      if (ParentList[(*iter)->getNr()]->father != (*iter)) {
-        status = false;
-      } else {
-        const BondList& ListOfBonds = (*iter)->getListOfBonds();
-        for (BondList::const_iterator Runner = ListOfBonds.begin();
-            Runner != ListOfBonds.end();
-            ++Runner) {
-          OtherAtom = (*Runner)->GetOtherAtom((*iter));
-          if (ParentList[OtherAtom->getNr()] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond
-            DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[(*iter)->getNr()]->getName() << " and " << ParentList[OtherAtom->getNr()]->getName() << "." << endl);
-            mol->AddBond(ParentList[(*iter)->getNr()], ParentList[OtherAtom->getNr()], (*Runner)->BondDegree);
-          }
-        }
-      }
-    }
-  }
-  return status;
-}
-;
-
-/** Adds bond structure to this molecule from \a Father molecule.
- * This basically causes this molecule to become an induced subgraph of the \a Father, i.e. for every bond in Father
- * with end points present in this molecule, bond is created in this molecule.
- * Special care was taken to ensure that this is of complexity O(N), where N is the \a Father's molecule::AtomCount.
- * \param *Father father molecule
- * \return true - is induced subgraph, false - there are atoms with fathers not in \a Father
- * \todo not checked, not fully working probably
- */
-bool molecule::BuildInducedSubgraph(const molecule *Father){
-  bool status = true;
-  atom **ParentList = NULL;
-  DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl);
-  BuildInducedSubgraph_Init(ParentList, Father->getAtomCount());
-  BuildInducedSubgraph_FillParentList(this, Father, ParentList);
-  status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList);
-  BuildInducedSubgraph_Finalize(ParentList);
-  DoLog(2) && (Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl);
-  return status;
-}
-;
-
 /** Fills a lookup list of father's Atom::nr -> atom for each subgraph.
  * \param **&ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
