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