Index: src/Actions/FragmentationAction/CreateAdjacencyAction.cpp
===================================================================
--- src/Actions/FragmentationAction/CreateAdjacencyAction.cpp	(revision efe5160ad303df71b958a8e888770461a77b5bae)
+++ 	(revision )
@@ -1,191 +1,0 @@
-/*
- * 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.
- */
-
-/*
- * CreateAdjacencyAction.cpp
- *
- *  Created on: May 9, 2010
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include "Descriptors/AtomIdDescriptor.hpp"
-#include "Descriptors/MoleculeDescriptor.hpp"
-
-#include "atom.hpp"
-#include "Bond/bond.hpp"
-#include "CodePatterns/Log.hpp"
-#include "CodePatterns/Range.hpp"
-#include "CodePatterns/Verbose.hpp"
-#include "config.hpp"
-#include "Graph/BondGraph.hpp"
-#include "linkedcell.hpp"
-#include "molecule.hpp"
-#include "PointCloudAdaptor.hpp"
-#include "World.hpp"
-#include "WorldTime.hpp"
-
-#include <iostream>
-#include <list>
-#include <string>
-
-typedef std::map< moleculeId_t, std::vector<atomId_t> > MolAtomList;
-
-using namespace std;
-
-#include "Actions/FragmentationAction/CreateAdjacencyAction.hpp"
-
-// and construct the stuff
-#include "CreateAdjacencyAction.def"
-#include "Action_impl_pre.hpp"
-/** =========== define the function ====================== */
-Action::state_ptr FragmentationCreateAdjacencyAction::performCall() {
-  // obtain information
-  getParametersfromValueStorage();
-
-  DoLog(1) && (Log() << Verbose(1) << "Constructing bond graph for selected atoms ... " << endl);
-
-  BondGraph *BG = World::getInstance().getBondGraph();
-  ASSERT(BG != NULL, "FragmentationCreateAdjacencyAction: BondGraph is NULL.");
-  double BondDistance = BG->getMaxPossibleBondDistance(AtomSetMixin<std::vector<atom *> >(World::getInstance().getSelectedAtoms()));
-
-  atom *Walker = NULL;
-  atom *OtherWalker = NULL;
-  int n[NDIM];
-  LinkedCell *LC = NULL;
-  Box &domain = World::getInstance().getDomain();
-
-  // remove every bond from the selected atoms' list
-  int AtomCount = 0;
-  for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection();
-      AtomRunner != World::getInstance().endAtomSelection();
-      ++AtomRunner) {
-    AtomCount++;
-    BondList& ListOfBonds = (AtomRunner->second)->getListOfBonds();
-    for(BondList::iterator BondRunner = ListOfBonds.begin();
-        !ListOfBonds.empty();
-        BondRunner = ListOfBonds.begin())
-      if ((*BondRunner)->leftatom == AtomRunner->second)
-        delete((*BondRunner));
-  }
-  int BondCount = 0;
-
-  // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering)
-  DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << BondDistance << "." << endl);
-
-  if ((AtomCount > 1) && (BondDistance > 1.)) {
-    DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl);
-    TesselPointSTLList list;
-    for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection();
-        AtomRunner != World::getInstance().endAtomSelection();
-        ++AtomRunner) {
-      list.push_back(AtomRunner->second);
-    }
-    PointCloudAdaptor< TesselPointSTLList > cloud(&list, "AtomSelection");
-    LC = new LinkedCell(cloud, BondDistance);
-
-    // create a list to map Tesselpoint::Nr to atom *
-    DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl);
-
-    // set numbers for atoms that can later be used
-    std::map<TesselPoint *, int> AtomIds;
-    int i=0;
-    for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection();
-        AtomRunner != World::getInstance().endAtomSelection();
-        ++AtomRunner) {
-      AtomIds.insert(pair<TesselPoint *, int> (AtomRunner->second, i++) );
-    }
-
-    // 3a. go through every cell
-    DoLog(2) && (Log() << Verbose(2) << "Celling ... " << endl);
-    for (LC->n[0] = 0; LC->n[0] < LC->N[0]; LC->n[0]++)
-      for (LC->n[1] = 0; LC->n[1] < LC->N[1]; LC->n[1]++)
-        for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) {
-          const TesselPointSTLList *List = LC->GetCurrentCell();
-//          Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
-          if (List != NULL) {
-            for (TesselPointSTLList::const_iterator Runner = List->begin();
-                Runner != List->end();
-                Runner++) {
-              Walker = dynamic_cast<atom*>(*Runner);
-              ASSERT(Walker,"Tesselpoint that was not an atom retrieved from LinkedNode");
-              //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
-              // 3c. check for possible bond between each atom in this and every one in the 27 cells
-              for (n[0] = -1; n[0] <= 1; n[0]++)
-                for (n[1] = -1; n[1] <= 1; n[1]++)
-                  for (n[2] = -1; n[2] <= 1; n[2]++) {
-                    const TesselPointSTLList *OtherList = LC->GetRelativeToCurrentCell(n);
-//                    Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
-                    if (OtherList != NULL) {
-                      for (TesselPointSTLList::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
-                        if (AtomIds.find(*OtherRunner)->second > AtomIds.find(Walker)->second) {
-                          OtherWalker = dynamic_cast<atom*>(*OtherRunner);
-                          ASSERT(OtherWalker,"TesselPoint that was not an atom retrieved from LinkedNode");
-                          //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
-                          const range<double> MinMaxDistanceSquared(
-                              BG->getMinMaxDistanceSquared(Walker, OtherWalker));
-                          const double distance = domain.periodicDistanceSquared(OtherWalker->getPosition(),Walker->getPosition());
-                          const bool status = MinMaxDistanceSquared.isInRange(distance);
-//                          LOG3, "INFO: MinMaxDistanceSquared interval is " << MinMaxDistanceSquared << ".");
-                          if (AtomIds[OtherWalker->father] > AtomIds[Walker->father]) {
-                            if (status) { // create bond if distance is smaller
-//                              Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl;
-                              bond * const Binder = new bond(Walker->father, OtherWalker->father, 1);
-                              BondCount++;
-                              Walker->father->RegisterBond(WorldTime::getTime(),Binder);
-                              OtherWalker->father->RegisterBond(WorldTime::getTime(),Binder);
-                            } else {
-//                              Log() << Verbose(1) << "Not Adding: distance too great." << endl;
-                            }
-                          } else {
-//                            Log() << Verbose(1) << "Not Adding: Wrong order of labels." << endl;
-                          }
-                        }
-                      }
-                    }
-                  }
-            }
-          }
-        }
-    delete (LC);
-    DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl);
-
-    // correct bond degree by comparing valence and bond degree
-    DoLog(2) && (Log() << Verbose(2) << "Correcting bond degree ... " << endl);
-    //CorrectBondDegree();
-
-  } else
-    DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl);
-  DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl);
-
-  return Action::success;
-}
-
-Action::state_ptr FragmentationCreateAdjacencyAction::performUndo(Action::state_ptr _state) {
-//  FragmentationCreateAdjacencyState *state = assert_cast<FragmentationCreateAdjacencyState*>(_state.get());
-
-  return Action::success;
-}
-
-Action::state_ptr FragmentationCreateAdjacencyAction::performRedo(Action::state_ptr _state){
-  return Action::success;
-}
-
-bool FragmentationCreateAdjacencyAction::canUndo() {
-  return false;
-}
-
-bool FragmentationCreateAdjacencyAction::shouldUndo() {
-  return false;
-}
-/** =========== end of function ====================== */
Index: src/Actions/FragmentationAction/CreateAdjacencyAction.def
===================================================================
--- src/Actions/FragmentationAction/CreateAdjacencyAction.def	(revision efe5160ad303df71b958a8e888770461a77b5bae)
+++ 	(revision )
@@ -1,33 +1,0 @@
-/*
- * CreateAdjacencyAction.def
- *
- *  Created on: Aug 26, 2010
- *      Author: heber
- */
-
-// all includes and forward declarations necessary for non-integral types below
-
-
-// i.e. there is an integer with variable name Z that can be found in
-// ValueStorage by the token "Z" -> first column: int, Z, "Z"
-// "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value
-#undef paramtypes
-#undef paramtokens
-#undef paramdescriptions
-#undef paramdefaults
-#undef paramreferences
-
-#undef statetypes
-#undef statereferences
-
-// some defines for all the names, you may use ACTION, STATE and PARAMS
-#define CATEGORY Fragmentation
-#define MENUNAME "fragmentation"
-#define MENUPOSITION 1
-#define ACTIONNAME CreateAdjacency
-#define TOKEN "create-adjacency"
-
-
-// finally the information stored in the ActionTrait specialization
-#define DESCRIPTION "construct the bond graph of the selected atoms"
-#undef SHORTFORM
Index: src/Actions/FragmentationAction/CreateAdjacencyAction.hpp
===================================================================
--- src/Actions/FragmentationAction/CreateAdjacencyAction.hpp	(revision efe5160ad303df71b958a8e888770461a77b5bae)
+++ 	(revision )
@@ -1,22 +1,0 @@
-/*
- * CreateAdjacencyAction.hpp
- *
- *  Created on: May 9, 2010
- *      Author: heber
- */
-
-#ifndef CREATEADJACENCYACTION_HPP_
-#define CREATEADJACENCYACTION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include "Actions/Action.hpp"
-
-#include "CreateAdjacencyAction.def"
-#include "Action_impl_header.hpp"
-
-#endif /* CREATEADJACENCYACTION_HPP_ */
Index: src/Actions/FragmentationAction/DepthFirstSearchAction.cpp
===================================================================
--- src/Actions/FragmentationAction/DepthFirstSearchAction.cpp	(revision efe5160ad303df71b958a8e888770461a77b5bae)
+++ 	(revision )
@@ -1,93 +1,0 @@
-/*
- * 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.
- */
-
-/*
- * DepthFirstSearchAction.cpp
- *
- *  Created on: May 9, 2010
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include "atom.hpp"
-#include "Graph/BondGraph.hpp"
-#include "config.hpp"
-#include "CodePatterns/Log.hpp"
-#include "CodePatterns/Verbose.hpp"
-#include "Graph/CyclicStructureAnalysis.hpp"
-#include "Graph/DepthFirstSearchAnalysis.hpp"
-#include "molecule.hpp"
-#include "Descriptors/MoleculeDescriptor.hpp"
-#include "Descriptors/MoleculeIdDescriptor.hpp"
-#include "World.hpp"
-
-#include <iostream>
-#include <string>
-
-using namespace std;
-
-#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
-
-// and construct the stuff
-#include "DepthFirstSearchAction.def"
-#include "Action_impl_pre.hpp"
-/** =========== define the function ====================== */
-Action::state_ptr FragmentationDepthFirstSearchAction::performCall() {
-  // obtain information
-  getParametersfromValueStorage();
-
-  DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
-  atom **ListOfAtoms = NULL;
-  std::deque<bond *> *LocalBackEdgeStack = NULL;
-  DepthFirstSearchAnalysis DFS;
-  DFS();
-  DFS.UpdateMoleculeStructure();
-  MoleculeLeafClass *Subgraphs = DFS.getMoleculeStructure();
-  if (Subgraphs != NULL) {
-    int FragmentCounter = 0;
-    while (Subgraphs->next != NULL) {
-      Subgraphs = Subgraphs->next;
-      ListOfAtoms = NULL;
-      Subgraphs->Leaf->FillListOfLocalAtoms(ListOfAtoms, Subgraphs->Leaf->getAtomCount());
-      LocalBackEdgeStack = new std::deque<bond *>; // no need to have it Subgraphs->Leaf->BondCount size
-      DFS.PickLocalBackEdges(ListOfAtoms, LocalBackEdgeStack);
-      CyclicStructureAnalysis CycleAnalysis;
-      CycleAnalysis(LocalBackEdgeStack);
-      delete(LocalBackEdgeStack);
-      Subgraphs->Leaf = NULL;
-      delete(Subgraphs->previous);
-      delete[](ListOfAtoms);  // allocated by FillListOfLocalAtoms
-      FragmentCounter++;
-    }
-    Subgraphs->Leaf = NULL;
-    delete(Subgraphs);
-  }
-  return Action::success;
-}
-
-Action::state_ptr FragmentationDepthFirstSearchAction::performUndo(Action::state_ptr _state) {
-  return Action::success;
-}
-
-Action::state_ptr FragmentationDepthFirstSearchAction::performRedo(Action::state_ptr _state){
-  return Action::success;
-}
-
-bool FragmentationDepthFirstSearchAction::canUndo() {
-  return true;
-}
-
-bool FragmentationDepthFirstSearchAction::shouldUndo() {
-  return true;
-}
-/** =========== end of function ====================== */
Index: src/Actions/FragmentationAction/DepthFirstSearchAction.def
===================================================================
--- src/Actions/FragmentationAction/DepthFirstSearchAction.def	(revision efe5160ad303df71b958a8e888770461a77b5bae)
+++ 	(revision )
@@ -1,33 +1,0 @@
-/*
- * DepthFirstSearchAction.def
- *
- *  Created on: Aug 26, 2010
- *      Author: heber
- */
-
-// all includes and forward declarations necessary for non-integral types below
-
-
-// i.e. there is an integer with variable name Z that can be found in
-// ValueStorage by the token "Z" -> first column: int, Z, "Z"
-// "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value
-#define paramtypes (double)
-#define paramtokens ("depth-first-search")
-#define paramdescriptions ("maximum distance to look for neighbors")
-#undef paramdefaults
-#define paramreferences (distance)
-
-#undef statetypes
-#undef statereferences
-
-// some defines for all the names, you may use ACTION, STATE and PARAMS
-#define CATEGORY Fragmentation
-#define MENUNAME "fragmentation"
-#define MENUPOSITION 2
-#define ACTIONNAME DepthFirstSearch
-#define TOKEN "depth-first-search"
-
-
-// finally the information stored in the ActionTrait specialization
-#define DESCRIPTION "Depth-First Search analysis of the molecular system"
-#define SHORTFORM "D"
Index: src/Actions/FragmentationAction/DepthFirstSearchAction.hpp
===================================================================
--- src/Actions/FragmentationAction/DepthFirstSearchAction.hpp	(revision efe5160ad303df71b958a8e888770461a77b5bae)
+++ 	(revision )
@@ -1,22 +1,0 @@
-/*
- * DepthFirstSearchAction.hpp
- *
- *  Created on: May 9, 2010
- *      Author: heber
- */
-
-#ifndef DEPTHFIRSTSEARCHACTION_HPP_
-#define DEPTHFIRSTSEARCHACTION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include "Actions/Action.hpp"
-
-#include "DepthFirstSearchAction.def"
-#include "Action_impl_header.hpp"
-
-#endif /* DEPTHFIRSTSEARCHACTION_HPP_ */
Index: src/Actions/FragmentationAction/SubgraphDissectionAction.cpp
===================================================================
--- src/Actions/FragmentationAction/SubgraphDissectionAction.cpp	(revision efe5160ad303df71b958a8e888770461a77b5bae)
+++ 	(revision )
@@ -1,162 +1,0 @@
-/*
- * 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.
- */
-
-/*
- * SubgraphDissectionAction.cpp
- *
- *  Created on: May 9, 2010
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include "Descriptors/AtomIdDescriptor.hpp"
-#include "Descriptors/MoleculeDescriptor.hpp"
-
-#include "atom.hpp"
-#include "Bond/bond.hpp"
-#include "config.hpp"
-#include "CodePatterns/Log.hpp"
-#include "CodePatterns/Verbose.hpp"
-#include "Graph/BondGraph.hpp"
-#include "Graph/DepthFirstSearchAnalysis.hpp"
-#include "molecule.hpp"
-#include "World.hpp"
-
-#include <iostream>
-#include <string>
-
-typedef std::map< moleculeId_t, std::vector<atomId_t> > MolAtomList;
-typedef std::map< atomId_t, atomId_t > AtomAtomList;
-
-using namespace std;
-
-#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
-
-// and construct the stuff
-#include "SubgraphDissectionAction.def"
-#include "Action_impl_pre.hpp"
-/** =========== define the function ====================== */
-Action::state_ptr FragmentationSubgraphDissectionAction::performCall() {
-  // obtain information
-  getParametersfromValueStorage();
-
-
-  // first create stuff for undo state
-  LOG(0, "STATUS: Creating undo state.");
-  MolAtomList moleculelist;
-  vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
-  for (vector<molecule *>::const_iterator moliter = allmolecules.begin(); moliter != allmolecules.end(); ++moliter) {
-    std::vector<atomId_t> atomlist;
-    atomlist.resize((*moliter)->size());
-    for (molecule::const_iterator atomiter = (*moliter)->begin(); atomiter != (*moliter)->end(); ++atomiter) {
-      atomlist.push_back((*atomiter)->getId());
-    }
-    moleculelist.insert( std::pair< moleculeId_t, std::vector<atomId_t> > ((*moliter)->getId(), atomlist));
-  }
-  FragmentationSubgraphDissectionState *UndoState = new FragmentationSubgraphDissectionState(moleculelist, params);
-
-  // 0a. remove all present molecules
-  LOG(0, "STATUS: Removing all present molecules.");
-  MoleculeListClass *molecules = World::getInstance().getMolecules();
-  for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
-    molecules->erase(*MolRunner);
-    World::getInstance().destroyMolecule(*MolRunner);
-  }
-
-  // 0b. remove all bonds and construct a molecule with all atoms
-  molecule *mol = World::getInstance().createMolecule();
-  {
-    vector <atom *> allatoms = World::getInstance().getAllAtoms();
-    for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
-//      const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
-//      for(BondList::iterator BondRunner = ListOfBonds.begin();
-//          !ListOfBonds.empty();
-//          BondRunner = ListOfBonds.begin()) {
-//        delete(*BondRunner);
-//      }
-      mol->AddAtom(*AtomRunner);
-    }
-  }
-
-  // 1. create the bond structure of the single molecule
-  LOG(0, "STATUS: (Re-)constructing adjacency.");
-  if (mol->getBondCount() == 0) {
-    BondGraph *BG = World::getInstance().getBondGraph();
-    molecule::atomVector Set = mol->getAtomSet();
-    BG->CreateAdjacency(Set);
-//    if (mol->getBondCount() == 0) {
-//      World::getInstance().destroyMolecule(mol);
-//      ELOG(1, "There are no bonds.");
-//      return Action::failure;
-//    }
-  }
-
-  // 2. scan for connected subgraphs
-  DepthFirstSearchAnalysis DFS;
-  DFS();
-  DFS.UpdateMoleculeStructure();
-  if (!World::getInstance().numMolecules()) {
-    //World::getInstance().destroyMolecule(mol);
-    DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms." << endl);
-    return Action::failure;
-  }
-
-  DoLog(1) && (Log() << Verbose(1) << "I scanned " << World::getInstance().numMolecules() << " molecules." << endl);
-
-  return Action::state_ptr(UndoState);
-}
-
-Action::state_ptr FragmentationSubgraphDissectionAction::performUndo(Action::state_ptr _state) {
-  FragmentationSubgraphDissectionState *state = assert_cast<FragmentationSubgraphDissectionState*>(_state.get());
-
-  {
-    // remove all present molecules
-    MoleculeListClass *molecules = World::getInstance().getMolecules();
-    vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
-    for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
-      molecules->erase(*MolRunner);
-      World::getInstance().destroyMolecule(*MolRunner);
-    }
-  }
-
-  {
-    // construct the old state
-    MoleculeListClass *molecules = World::getInstance().getMolecules();
-    molecule *mol = NULL;
-    for (MolAtomList::const_iterator iter = state->moleculelist.begin(); iter != state->moleculelist.end(); ++iter) {
-      mol = World::getInstance().createMolecule();
-      if (mol->getId() != (*iter).first)
-        World::getInstance().changeMoleculeId(mol->getId(), (*iter).first);
-      for (std::vector<atomId_t>::const_iterator atomiter = (*iter).second.begin(); atomiter != (*iter).second.end(); ++atomiter) {
-        atom *Walker = World::getInstance().getAtom(AtomById(*atomiter));
-        mol->AddAtom(Walker);
-      }
-      molecules->insert(mol);
-    }
-  }
-
-  return Action::state_ptr(_state);
-}
-
-Action::state_ptr FragmentationSubgraphDissectionAction::performRedo(Action::state_ptr _state){
-  return performCall();
-}
-
-bool FragmentationSubgraphDissectionAction::canUndo() {
-  return true;
-}
-
-bool FragmentationSubgraphDissectionAction::shouldUndo() {
-  return true;
-}
-/** =========== end of function ====================== */
Index: src/Actions/FragmentationAction/SubgraphDissectionAction.def
===================================================================
--- src/Actions/FragmentationAction/SubgraphDissectionAction.def	(revision efe5160ad303df71b958a8e888770461a77b5bae)
+++ 	(revision )
@@ -1,33 +1,0 @@
-/*
- * SubgraphDissectionAction.def
- *
- *  Created on: Aug 26, 2010
- *      Author: heber
- */
-
-// all includes and forward declarations necessary for non-integral types below
-
-
-// i.e. there is an integer with variable name Z that can be found in
-// ValueStorage by the token "Z" -> first column: int, Z, "Z"
-// "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value
-#undef paramtypes
-#undef paramtokens
-#undef paramdescriptions
-#undef paramdefaults
-#undef paramreferences
-
-#define statetypes (MolAtomList)
-#define statereferences (moleculelist)
-
-// some defines for all the names, you may use ACTION, STATE and PARAMS
-#define CATEGORY Fragmentation
-#define MENUNAME "fragmentation"
-#define MENUPOSITION 4
-#define ACTIONNAME SubgraphDissection
-#define TOKEN "subgraph-dissection"
-
-
-// finally the information stored in the ActionTrait specialization
-#define DESCRIPTION "dissect the molecular system into molecules representing disconnected subgraphs"
-#define SHORTFORM "I"
Index: src/Actions/FragmentationAction/SubgraphDissectionAction.hpp
===================================================================
--- src/Actions/FragmentationAction/SubgraphDissectionAction.hpp	(revision efe5160ad303df71b958a8e888770461a77b5bae)
+++ 	(revision )
@@ -1,22 +1,0 @@
-/*
- * SubgraphDissectionAction.hpp
- *
- *  Created on: May 9, 2010
- *      Author: heber
- */
-
-#ifndef SUBGRAPHDISSECTIONACTION_HPP_
-#define SUBGRAPHDISSECTIONACTION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include "Actions/Action.hpp"
-
-#include "SubgraphDissectionAction.def"
-#include "Action_impl_header.hpp"
-
-#endif /* SUBGRAPHDISSECTIONACTION_HPP_ */
Index: src/Actions/GraphAction/CreateAdjacencyAction.cpp
===================================================================
--- src/Actions/GraphAction/CreateAdjacencyAction.cpp	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
+++ src/Actions/GraphAction/CreateAdjacencyAction.cpp	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
@@ -0,0 +1,191 @@
+/*
+ * 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.
+ */
+
+/*
+ * CreateAdjacencyAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+
+#include "atom.hpp"
+#include "Bond/bond.hpp"
+#include "CodePatterns/Log.hpp"
+#include "CodePatterns/Range.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "config.hpp"
+#include "Graph/BondGraph.hpp"
+#include "linkedcell.hpp"
+#include "molecule.hpp"
+#include "PointCloudAdaptor.hpp"
+#include "World.hpp"
+#include "WorldTime.hpp"
+
+#include <iostream>
+#include <list>
+#include <string>
+
+typedef std::map< moleculeId_t, std::vector<atomId_t> > MolAtomList;
+
+using namespace std;
+
+#include "Actions/GraphAction/CreateAdjacencyAction.hpp"
+
+// and construct the stuff
+#include "CreateAdjacencyAction.def"
+#include "Action_impl_pre.hpp"
+/** =========== define the function ====================== */
+Action::state_ptr GraphCreateAdjacencyAction::performCall() {
+  // obtain information
+  getParametersfromValueStorage();
+
+  DoLog(1) && (Log() << Verbose(1) << "Constructing bond graph for selected atoms ... " << endl);
+
+  BondGraph *BG = World::getInstance().getBondGraph();
+  ASSERT(BG != NULL, "GraphCreateAdjacencyAction: BondGraph is NULL.");
+  double BondDistance = BG->getMaxPossibleBondDistance(AtomSetMixin<std::vector<atom *> >(World::getInstance().getSelectedAtoms()));
+
+  atom *Walker = NULL;
+  atom *OtherWalker = NULL;
+  int n[NDIM];
+  LinkedCell *LC = NULL;
+  Box &domain = World::getInstance().getDomain();
+
+  // remove every bond from the selected atoms' list
+  int AtomCount = 0;
+  for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection();
+      AtomRunner != World::getInstance().endAtomSelection();
+      ++AtomRunner) {
+    AtomCount++;
+    BondList& ListOfBonds = (AtomRunner->second)->getListOfBonds();
+    for(BondList::iterator BondRunner = ListOfBonds.begin();
+        !ListOfBonds.empty();
+        BondRunner = ListOfBonds.begin())
+      if ((*BondRunner)->leftatom == AtomRunner->second)
+        delete((*BondRunner));
+  }
+  int BondCount = 0;
+
+  // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering)
+  DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << BondDistance << "." << endl);
+
+  if ((AtomCount > 1) && (BondDistance > 1.)) {
+    DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl);
+    TesselPointSTLList list;
+    for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection();
+        AtomRunner != World::getInstance().endAtomSelection();
+        ++AtomRunner) {
+      list.push_back(AtomRunner->second);
+    }
+    PointCloudAdaptor< TesselPointSTLList > cloud(&list, "AtomSelection");
+    LC = new LinkedCell(cloud, BondDistance);
+
+    // create a list to map Tesselpoint::Nr to atom *
+    DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl);
+
+    // set numbers for atoms that can later be used
+    std::map<TesselPoint *, int> AtomIds;
+    int i=0;
+    for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection();
+        AtomRunner != World::getInstance().endAtomSelection();
+        ++AtomRunner) {
+      AtomIds.insert(pair<TesselPoint *, int> (AtomRunner->second, i++) );
+    }
+
+    // 3a. go through every cell
+    DoLog(2) && (Log() << Verbose(2) << "Celling ... " << endl);
+    for (LC->n[0] = 0; LC->n[0] < LC->N[0]; LC->n[0]++)
+      for (LC->n[1] = 0; LC->n[1] < LC->N[1]; LC->n[1]++)
+        for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) {
+          const TesselPointSTLList *List = LC->GetCurrentCell();
+//          Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
+          if (List != NULL) {
+            for (TesselPointSTLList::const_iterator Runner = List->begin();
+                Runner != List->end();
+                Runner++) {
+              Walker = dynamic_cast<atom*>(*Runner);
+              ASSERT(Walker,"Tesselpoint that was not an atom retrieved from LinkedNode");
+              //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
+              // 3c. check for possible bond between each atom in this and every one in the 27 cells
+              for (n[0] = -1; n[0] <= 1; n[0]++)
+                for (n[1] = -1; n[1] <= 1; n[1]++)
+                  for (n[2] = -1; n[2] <= 1; n[2]++) {
+                    const TesselPointSTLList *OtherList = LC->GetRelativeToCurrentCell(n);
+//                    Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
+                    if (OtherList != NULL) {
+                      for (TesselPointSTLList::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
+                        if (AtomIds.find(*OtherRunner)->second > AtomIds.find(Walker)->second) {
+                          OtherWalker = dynamic_cast<atom*>(*OtherRunner);
+                          ASSERT(OtherWalker,"TesselPoint that was not an atom retrieved from LinkedNode");
+                          //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
+                          const range<double> MinMaxDistanceSquared(
+                              BG->getMinMaxDistanceSquared(Walker, OtherWalker));
+                          const double distance = domain.periodicDistanceSquared(OtherWalker->getPosition(),Walker->getPosition());
+                          const bool status = MinMaxDistanceSquared.isInRange(distance);
+//                          LOG3, "INFO: MinMaxDistanceSquared interval is " << MinMaxDistanceSquared << ".");
+                          if (AtomIds[OtherWalker->father] > AtomIds[Walker->father]) {
+                            if (status) { // create bond if distance is smaller
+//                              Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl;
+                              bond * const Binder = new bond(Walker->father, OtherWalker->father, 1);
+                              BondCount++;
+                              Walker->father->RegisterBond(WorldTime::getTime(),Binder);
+                              OtherWalker->father->RegisterBond(WorldTime::getTime(),Binder);
+                            } else {
+//                              Log() << Verbose(1) << "Not Adding: distance too great." << endl;
+                            }
+                          } else {
+//                            Log() << Verbose(1) << "Not Adding: Wrong order of labels." << endl;
+                          }
+                        }
+                      }
+                    }
+                  }
+            }
+          }
+        }
+    delete (LC);
+    DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl);
+
+    // correct bond degree by comparing valence and bond degree
+    DoLog(2) && (Log() << Verbose(2) << "Correcting bond degree ... " << endl);
+    //CorrectBondDegree();
+
+  } else
+    DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl);
+  DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl);
+
+  return Action::success;
+}
+
+Action::state_ptr GraphCreateAdjacencyAction::performUndo(Action::state_ptr _state) {
+//  GraphCreateAdjacencyState *state = assert_cast<GraphCreateAdjacencyState*>(_state.get());
+
+  return Action::success;
+}
+
+Action::state_ptr GraphCreateAdjacencyAction::performRedo(Action::state_ptr _state){
+  return Action::success;
+}
+
+bool GraphCreateAdjacencyAction::canUndo() {
+  return false;
+}
+
+bool GraphCreateAdjacencyAction::shouldUndo() {
+  return false;
+}
+/** =========== end of function ====================== */
Index: src/Actions/GraphAction/CreateAdjacencyAction.def
===================================================================
--- src/Actions/GraphAction/CreateAdjacencyAction.def	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
+++ src/Actions/GraphAction/CreateAdjacencyAction.def	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
@@ -0,0 +1,33 @@
+/*
+ * CreateAdjacencyAction.def
+ *
+ *  Created on: Aug 26, 2010
+ *      Author: heber
+ */
+
+// all includes and forward declarations necessary for non-integral types below
+
+
+// i.e. there is an integer with variable name Z that can be found in
+// ValueStorage by the token "Z" -> first column: int, Z, "Z"
+// "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value
+#undef paramtypes
+#undef paramtokens
+#undef paramdescriptions
+#undef paramdefaults
+#undef paramreferences
+
+#undef statetypes
+#undef statereferences
+
+// some defines for all the names, you may use ACTION, STATE and PARAMS
+#define CATEGORY Graph
+#define MENUNAME "graph"
+#define MENUPOSITION 1
+#define ACTIONNAME CreateAdjacency
+#define TOKEN "create-adjacency"
+
+
+// finally the information stored in the ActionTrait specialization
+#define DESCRIPTION "construct the bond graph of the selected atoms"
+#undef SHORTFORM
Index: src/Actions/GraphAction/CreateAdjacencyAction.hpp
===================================================================
--- src/Actions/GraphAction/CreateAdjacencyAction.hpp	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
+++ src/Actions/GraphAction/CreateAdjacencyAction.hpp	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
@@ -0,0 +1,22 @@
+/*
+ * CreateAdjacencyAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef CREATEADJACENCYACTION_HPP_
+#define CREATEADJACENCYACTION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "Actions/Action.hpp"
+
+#include "CreateAdjacencyAction.def"
+#include "Action_impl_header.hpp"
+
+#endif /* CREATEADJACENCYACTION_HPP_ */
Index: src/Actions/GraphAction/DepthFirstSearchAction.cpp
===================================================================
--- src/Actions/GraphAction/DepthFirstSearchAction.cpp	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
+++ src/Actions/GraphAction/DepthFirstSearchAction.cpp	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+/*
+ * DepthFirstSearchAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "atom.hpp"
+#include "Graph/BondGraph.hpp"
+#include "config.hpp"
+#include "CodePatterns/Log.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "Graph/CyclicStructureAnalysis.hpp"
+#include "Graph/DepthFirstSearchAnalysis.hpp"
+#include "molecule.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+#include "Descriptors/MoleculeIdDescriptor.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+#include "Actions/GraphAction/DepthFirstSearchAction.hpp"
+
+// and construct the stuff
+#include "DepthFirstSearchAction.def"
+#include "Action_impl_pre.hpp"
+/** =========== define the function ====================== */
+Action::state_ptr GraphDepthFirstSearchAction::performCall() {
+  // obtain information
+  getParametersfromValueStorage();
+
+  DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
+  atom **ListOfAtoms = NULL;
+  std::deque<bond *> *LocalBackEdgeStack = NULL;
+  DepthFirstSearchAnalysis DFS;
+  DFS();
+  DFS.UpdateMoleculeStructure();
+  MoleculeLeafClass *Subgraphs = DFS.getMoleculeStructure();
+  if (Subgraphs != NULL) {
+    int FragmentCounter = 0;
+    while (Subgraphs->next != NULL) {
+      Subgraphs = Subgraphs->next;
+      ListOfAtoms = NULL;
+      Subgraphs->Leaf->FillListOfLocalAtoms(ListOfAtoms, Subgraphs->Leaf->getAtomCount());
+      LocalBackEdgeStack = new std::deque<bond *>; // no need to have it Subgraphs->Leaf->BondCount size
+      DFS.PickLocalBackEdges(ListOfAtoms, LocalBackEdgeStack);
+      CyclicStructureAnalysis CycleAnalysis;
+      CycleAnalysis(LocalBackEdgeStack);
+      delete(LocalBackEdgeStack);
+      Subgraphs->Leaf = NULL;
+      delete(Subgraphs->previous);
+      delete[](ListOfAtoms);  // allocated by FillListOfLocalAtoms
+      FragmentCounter++;
+    }
+    Subgraphs->Leaf = NULL;
+    delete(Subgraphs);
+  }
+  return Action::success;
+}
+
+Action::state_ptr GraphDepthFirstSearchAction::performUndo(Action::state_ptr _state) {
+  return Action::success;
+}
+
+Action::state_ptr GraphDepthFirstSearchAction::performRedo(Action::state_ptr _state){
+  return Action::success;
+}
+
+bool GraphDepthFirstSearchAction::canUndo() {
+  return true;
+}
+
+bool GraphDepthFirstSearchAction::shouldUndo() {
+  return true;
+}
+/** =========== end of function ====================== */
Index: src/Actions/GraphAction/DepthFirstSearchAction.def
===================================================================
--- src/Actions/GraphAction/DepthFirstSearchAction.def	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
+++ src/Actions/GraphAction/DepthFirstSearchAction.def	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
@@ -0,0 +1,33 @@
+/*
+ * DepthFirstSearchAction.def
+ *
+ *  Created on: Aug 26, 2010
+ *      Author: heber
+ */
+
+// all includes and forward declarations necessary for non-integral types below
+
+
+// i.e. there is an integer with variable name Z that can be found in
+// ValueStorage by the token "Z" -> first column: int, Z, "Z"
+// "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value
+#define paramtypes (double)
+#define paramtokens ("depth-first-search")
+#define paramdescriptions ("maximum distance to look for neighbors")
+#undef paramdefaults
+#define paramreferences (distance)
+
+#undef statetypes
+#undef statereferences
+
+// some defines for all the names, you may use ACTION, STATE and PARAMS
+#define CATEGORY Graph
+#define MENUNAME "graph"
+#define MENUPOSITION 2
+#define ACTIONNAME DepthFirstSearch
+#define TOKEN "depth-first-search"
+
+
+// finally the information stored in the ActionTrait specialization
+#define DESCRIPTION "Depth-First Search analysis of the molecular system"
+#define SHORTFORM "D"
Index: src/Actions/GraphAction/DepthFirstSearchAction.hpp
===================================================================
--- src/Actions/GraphAction/DepthFirstSearchAction.hpp	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
+++ src/Actions/GraphAction/DepthFirstSearchAction.hpp	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
@@ -0,0 +1,22 @@
+/*
+ * DepthFirstSearchAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef DEPTHFIRSTSEARCHACTION_HPP_
+#define DEPTHFIRSTSEARCHACTION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "Actions/Action.hpp"
+
+#include "DepthFirstSearchAction.def"
+#include "Action_impl_header.hpp"
+
+#endif /* DEPTHFIRSTSEARCHACTION_HPP_ */
Index: src/Actions/GraphAction/SubgraphDissectionAction.cpp
===================================================================
--- src/Actions/GraphAction/SubgraphDissectionAction.cpp	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
+++ src/Actions/GraphAction/SubgraphDissectionAction.cpp	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
@@ -0,0 +1,162 @@
+/*
+ * 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.
+ */
+
+/*
+ * SubgraphDissectionAction.cpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "Descriptors/MoleculeDescriptor.hpp"
+
+#include "atom.hpp"
+#include "Bond/bond.hpp"
+#include "config.hpp"
+#include "CodePatterns/Log.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "Graph/BondGraph.hpp"
+#include "Graph/DepthFirstSearchAnalysis.hpp"
+#include "molecule.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+typedef std::map< moleculeId_t, std::vector<atomId_t> > MolAtomList;
+typedef std::map< atomId_t, atomId_t > AtomAtomList;
+
+using namespace std;
+
+#include "Actions/GraphAction/SubgraphDissectionAction.hpp"
+
+// and construct the stuff
+#include "SubgraphDissectionAction.def"
+#include "Action_impl_pre.hpp"
+/** =========== define the function ====================== */
+Action::state_ptr GraphSubgraphDissectionAction::performCall() {
+  // obtain information
+  getParametersfromValueStorage();
+
+
+  // first create stuff for undo state
+  LOG(0, "STATUS: Creating undo state.");
+  MolAtomList moleculelist;
+  vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
+  for (vector<molecule *>::const_iterator moliter = allmolecules.begin(); moliter != allmolecules.end(); ++moliter) {
+    std::vector<atomId_t> atomlist;
+    atomlist.resize((*moliter)->size());
+    for (molecule::const_iterator atomiter = (*moliter)->begin(); atomiter != (*moliter)->end(); ++atomiter) {
+      atomlist.push_back((*atomiter)->getId());
+    }
+    moleculelist.insert( std::pair< moleculeId_t, std::vector<atomId_t> > ((*moliter)->getId(), atomlist));
+  }
+  GraphSubgraphDissectionState *UndoState = new GraphSubgraphDissectionState(moleculelist, params);
+
+  // 0a. remove all present molecules
+  LOG(0, "STATUS: Removing all present molecules.");
+  MoleculeListClass *molecules = World::getInstance().getMolecules();
+  for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
+    molecules->erase(*MolRunner);
+    World::getInstance().destroyMolecule(*MolRunner);
+  }
+
+  // 0b. remove all bonds and construct a molecule with all atoms
+  molecule *mol = World::getInstance().createMolecule();
+  {
+    vector <atom *> allatoms = World::getInstance().getAllAtoms();
+    for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
+//      const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
+//      for(BondList::iterator BondRunner = ListOfBonds.begin();
+//          !ListOfBonds.empty();
+//          BondRunner = ListOfBonds.begin()) {
+//        delete(*BondRunner);
+//      }
+      mol->AddAtom(*AtomRunner);
+    }
+  }
+
+  // 1. create the bond structure of the single molecule
+  LOG(0, "STATUS: (Re-)constructing adjacency.");
+  if (mol->getBondCount() == 0) {
+    BondGraph *BG = World::getInstance().getBondGraph();
+    molecule::atomVector Set = mol->getAtomSet();
+    BG->CreateAdjacency(Set);
+//    if (mol->getBondCount() == 0) {
+//      World::getInstance().destroyMolecule(mol);
+//      ELOG(1, "There are no bonds.");
+//      return Action::failure;
+//    }
+  }
+
+  // 2. scan for connected subgraphs
+  DepthFirstSearchAnalysis DFS;
+  DFS();
+  DFS.UpdateMoleculeStructure();
+  if (!World::getInstance().numMolecules()) {
+    //World::getInstance().destroyMolecule(mol);
+    DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms." << endl);
+    return Action::failure;
+  }
+
+  DoLog(1) && (Log() << Verbose(1) << "I scanned " << World::getInstance().numMolecules() << " molecules." << endl);
+
+  return Action::state_ptr(UndoState);
+}
+
+Action::state_ptr GraphSubgraphDissectionAction::performUndo(Action::state_ptr _state) {
+  GraphSubgraphDissectionState *state = assert_cast<GraphSubgraphDissectionState*>(_state.get());
+
+  {
+    // remove all present molecules
+    MoleculeListClass *molecules = World::getInstance().getMolecules();
+    vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
+    for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
+      molecules->erase(*MolRunner);
+      World::getInstance().destroyMolecule(*MolRunner);
+    }
+  }
+
+  {
+    // construct the old state
+    MoleculeListClass *molecules = World::getInstance().getMolecules();
+    molecule *mol = NULL;
+    for (MolAtomList::const_iterator iter = state->moleculelist.begin(); iter != state->moleculelist.end(); ++iter) {
+      mol = World::getInstance().createMolecule();
+      if (mol->getId() != (*iter).first)
+        World::getInstance().changeMoleculeId(mol->getId(), (*iter).first);
+      for (std::vector<atomId_t>::const_iterator atomiter = (*iter).second.begin(); atomiter != (*iter).second.end(); ++atomiter) {
+        atom *Walker = World::getInstance().getAtom(AtomById(*atomiter));
+        mol->AddAtom(Walker);
+      }
+      molecules->insert(mol);
+    }
+  }
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr GraphSubgraphDissectionAction::performRedo(Action::state_ptr _state){
+  return performCall();
+}
+
+bool GraphSubgraphDissectionAction::canUndo() {
+  return true;
+}
+
+bool GraphSubgraphDissectionAction::shouldUndo() {
+  return true;
+}
+/** =========== end of function ====================== */
Index: src/Actions/GraphAction/SubgraphDissectionAction.def
===================================================================
--- src/Actions/GraphAction/SubgraphDissectionAction.def	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
+++ src/Actions/GraphAction/SubgraphDissectionAction.def	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
@@ -0,0 +1,33 @@
+/*
+ * SubgraphDissectionAction.def
+ *
+ *  Created on: Aug 26, 2010
+ *      Author: heber
+ */
+
+// all includes and forward declarations necessary for non-integral types below
+
+
+// i.e. there is an integer with variable name Z that can be found in
+// ValueStorage by the token "Z" -> first column: int, Z, "Z"
+// "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value
+#undef paramtypes
+#undef paramtokens
+#undef paramdescriptions
+#undef paramdefaults
+#undef paramreferences
+
+#define statetypes (MolAtomList)
+#define statereferences (moleculelist)
+
+// some defines for all the names, you may use ACTION, STATE and PARAMS
+#define CATEGORY Graph
+#define MENUNAME "graph"
+#define MENUPOSITION 4
+#define ACTIONNAME SubgraphDissection
+#define TOKEN "subgraph-dissection"
+
+
+// finally the information stored in the ActionTrait specialization
+#define DESCRIPTION "dissect the molecular system into molecules representing disconnected subgraphs"
+#define SHORTFORM "I"
Index: src/Actions/GraphAction/SubgraphDissectionAction.hpp
===================================================================
--- src/Actions/GraphAction/SubgraphDissectionAction.hpp	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
+++ src/Actions/GraphAction/SubgraphDissectionAction.hpp	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
@@ -0,0 +1,22 @@
+/*
+ * SubgraphDissectionAction.hpp
+ *
+ *  Created on: May 9, 2010
+ *      Author: heber
+ */
+
+#ifndef SUBGRAPHDISSECTIONACTION_HPP_
+#define SUBGRAPHDISSECTIONACTION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "Actions/Action.hpp"
+
+#include "SubgraphDissectionAction.def"
+#include "Action_impl_header.hpp"
+
+#endif /* SUBGRAPHDISSECTIONACTION_HPP_ */
Index: src/Actions/Makefile.am
===================================================================
--- src/Actions/Makefile.am	(revision efe5160ad303df71b958a8e888770461a77b5bae)
+++ src/Actions/Makefile.am	(revision d09093c691897e07d538a3b07ec8605572e2d8a9)
@@ -12,4 +12,5 @@
   ${CMDACTIONSOURCE} \
   ${FRAGMENTATIONACTIONSOURCE} \
+  ${GRAPHACTIONSOURCE} \
   ${MOLECULEACTIONSOURCE} \
   ${PARSERACTIONSOURCE} \
@@ -29,4 +30,5 @@
   ${CMDACTIONHEADER} \
   ${FRAGMENTATIONACTIONHEADER} \
+  ${GRAPHACTIONHEADER} \
   ${MOLECULEACTIONHEADER} \
   ${PARSERACTIONHEADER} \
@@ -87,13 +89,16 @@
 
 FRAGMENTATIONACTIONSOURCE = \
-  FragmentationAction/CreateAdjacencyAction.cpp \
-  FragmentationAction/DepthFirstSearchAction.cpp \
-  FragmentationAction/FragmentationAction.cpp \
-  FragmentationAction/SubgraphDissectionAction.cpp               
+  FragmentationAction/FragmentationAction.cpp
 FRAGMENTATIONACTIONHEADER = \
-  FragmentationAction/CreateAdjacencyAction.hpp \
-  FragmentationAction/DepthFirstSearchAction.hpp \
-  FragmentationAction/FragmentationAction.hpp \
-  FragmentationAction/SubgraphDissectionAction.hpp
+  FragmentationAction/FragmentationAction.hpp
+
+GRAPHACTIONSOURCE = \
+  GraphAction/CreateAdjacencyAction.cpp \
+  GraphAction/DepthFirstSearchAction.cpp \
+  GraphAction/SubgraphDissectionAction.cpp
+GRAPHACTIONHEADER = \
+  GraphAction/CreateAdjacencyAction.hpp \
+  GraphAction/DepthFirstSearchAction.hpp \
+  GraphAction/SubgraphDissectionAction.hpp
 
 MOLECULEACTIONSOURCE = \
