[7b6b21f] | 1 | /*
|
---|
| 2 | * HomologyGraph.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Sep 24, 2012
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef HOMOLOGYGRAPH_HPP_
|
---|
| 9 | #define HOMOLOGYGRAPH_HPP_
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | // include config.h
|
---|
| 13 | #ifdef HAVE_CONFIG_H
|
---|
| 14 | #include <config.h>
|
---|
| 15 | #endif
|
---|
| 16 |
|
---|
[67db80] | 17 | #include <boost/serialization/export.hpp>
|
---|
| 18 | #include <boost/serialization/set.hpp>
|
---|
| 19 |
|
---|
[7b6b21f] | 20 | #include <set>
|
---|
[54a561] | 21 | #include <iosfwd>
|
---|
[7b6b21f] | 22 |
|
---|
| 23 | #include "Fragmentation/Homology/FragmentEdge.hpp"
|
---|
| 24 | #include "Fragmentation/Homology/FragmentNode.hpp"
|
---|
| 25 |
|
---|
[77b350] | 26 | class KeySet;
|
---|
| 27 |
|
---|
[7b6b21f] | 28 | /** This class contains the representation of a molecular fragment as a graph.
|
---|
| 29 | *
|
---|
| 30 | * Only, we do not store the full graph in here. We have to include symmetries
|
---|
| 31 | * such that two hydrogens may switch places. Eventually, we only look for the
|
---|
| 32 | * set of distances of a fragment. If two hydrogens switch places, then also in
|
---|
| 33 | * the set of distances some distances are interchanged but the whole fragment
|
---|
| 34 | * remains the same. Hence, we have to store the bond graph representation in
|
---|
| 35 | * such a way as to automatically include these symmetries.
|
---|
| 36 | *
|
---|
| 37 | * To this end, we use FragmentNode and FragmentEdge to store the vital
|
---|
| 38 | * information.
|
---|
| 39 | *
|
---|
| 40 | */
|
---|
| 41 | class HomologyGraph
|
---|
| 42 | {
|
---|
[54a561] | 43 | //!> grant output operator access to internals
|
---|
| 44 | friend std::ostream& operator<<(std::ostream& ost, const HomologyGraph &graph);
|
---|
[7b6b21f] | 45 | public:
|
---|
| 46 | //!> typedef for a set of nodes representing node information
|
---|
| 47 | typedef std::set<FragmentNode> nodes_t;
|
---|
| 48 | //!> typedef for a set of nodes representing edge information
|
---|
| 49 | typedef std::set<FragmentEdge> edges_t;
|
---|
| 50 | public:
|
---|
| 51 | /** Default constructor for class HomologyGraph.
|
---|
| 52 | *
|
---|
| 53 | * This is required to allow placement in STL containers
|
---|
| 54 | *
|
---|
| 55 | */
|
---|
| 56 | HomologyGraph() {}
|
---|
| 57 |
|
---|
| 58 | /** Constructor for class HomologyGraph.
|
---|
| 59 | *
|
---|
| 60 | * @param _nodes information on nodes of this graph
|
---|
| 61 | * @param _edges information on edges of this graph
|
---|
| 62 | */
|
---|
| 63 | HomologyGraph(const nodes_t &_nodes, const edges_t &_edges) :
|
---|
| 64 | nodes(_nodes),
|
---|
| 65 | edges(_edges)
|
---|
| 66 | {}
|
---|
| 67 |
|
---|
[77b350] | 68 | /** Constructor for class HomologyGraph from a keyset (i.e. from atoms in the World).
|
---|
| 69 | *
|
---|
| 70 | * @param keyset global ids of atoms to pick
|
---|
| 71 | */
|
---|
| 72 | HomologyGraph(const KeySet &keyset);
|
---|
| 73 |
|
---|
[7b6b21f] | 74 | /** Destructor for class HomologyGraph.
|
---|
| 75 | *
|
---|
| 76 | */
|
---|
| 77 | ~HomologyGraph() {}
|
---|
| 78 |
|
---|
| 79 | // comparators (allows sorting and hence quicker finding in STL containers)
|
---|
| 80 | bool operator<(const HomologyGraph &graph) const;
|
---|
| 81 | bool operator>(const HomologyGraph &graph) const;
|
---|
| 82 | bool operator==(const HomologyGraph &graph) const;
|
---|
| 83 | bool operator!=(const HomologyGraph &graph) const {
|
---|
| 84 | return (!(*this == graph));
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | /** Assignment operator for class HomologyGraph.
|
---|
| 88 | *
|
---|
| 89 | * This is required to allow placement in STL container as we need to
|
---|
| 90 | * const_cast override our const member variables.
|
---|
| 91 | *
|
---|
| 92 | */
|
---|
| 93 | HomologyGraph& operator=(const HomologyGraph &graph);
|
---|
| 94 |
|
---|
| 95 | private:
|
---|
| 96 | //!> information on the nodes of the graph
|
---|
| 97 | const nodes_t nodes;
|
---|
| 98 | //!> information on the edges of the graph
|
---|
| 99 | const edges_t edges;
|
---|
[67db80] | 100 |
|
---|
| 101 | private:
|
---|
| 102 | friend class boost::serialization::access;
|
---|
| 103 | // serialization
|
---|
| 104 | template <typename Archive>
|
---|
| 105 | void serialize(Archive& ar, const unsigned int version)
|
---|
| 106 | {
|
---|
| 107 | ar & const_cast<nodes_t &>(nodes);
|
---|
| 108 | ar & const_cast<edges_t &>(edges);
|
---|
| 109 | }
|
---|
[7b6b21f] | 110 | };
|
---|
| 111 |
|
---|
[54a561] | 112 | std::ostream& operator<<(std::ostream& ost, const HomologyGraph &graph);
|
---|
| 113 |
|
---|
[67db80] | 114 | // we need to give this class a unique key for serialization
|
---|
| 115 | BOOST_CLASS_EXPORT_KEY(HomologyGraph)
|
---|
| 116 |
|
---|
[77b350] | 117 | // define some helpers outside to allow for light-weight unit testing
|
---|
| 118 | namespace detail {
|
---|
| 119 | const HomologyGraph::nodes_t getNodesFromKeySet(const KeySet &keyset);
|
---|
| 120 | const HomologyGraph::edges_t getEdgesFromKeySet(const KeySet &keyset);
|
---|
| 121 | };
|
---|
| 122 |
|
---|
[7b6b21f] | 123 |
|
---|
| 124 | #endif /* HOMOLOGYGRAPH_HPP_ */
|
---|