7 #ifndef IMPMULTIFIT_MERGE_TREE_UTILS_H
8 #define IMPMULTIFIT_MERGE_TREE_UTILS_H
10 #include <boost/functional/hash.hpp>
14 #include <boost/version.hpp>
15 #if BOOST_VERSION == 106000
16 # include <boost/type_traits/ice.hpp>
19 #include <boost/graph/adjacency_matrix.hpp>
20 #include <boost/graph/adjacency_list.hpp>
21 #include <boost/pending/disjoint_sets.hpp>
22 #include <boost/graph/graph_utility.hpp>
23 #include <IMP/multifit/multifit_config.h>
25 #include <boost/unordered_map.hpp>
26 #include <boost/graph/kruskal_min_spanning_tree.hpp>
27 #include <boost/graph/prim_minimum_spanning_tree.hpp>
29 IMPMULTIFIT_BEGIN_NAMESPACE
32 typedef boost::adjacency_matrix<boost::undirectedS, boost::no_property,
33 boost::property<boost::edge_weight_t, double> >
35 typedef boost::graph_traits<DependencyGraph>::edge_descriptor DGEdge;
36 typedef DependencyGraph::edge_property_type DGWeight;
37 typedef boost::graph_traits<DependencyGraph>::vertex_descriptor DGVertex;
38 typedef boost::unordered_map<Particle *, DGVertex> PVMAP;
39 typedef boost::unordered_map<DGVertex, Particle *> VPMAP;
46 :
Restraint(a->get_model(),
"DummyRestraint%1%"),
64 typedef boost::graph_traits<MTU::DependencyGraph>::vertex_iterator
66 VertexIterator v_it, v_it_end;
67 boost::tie(v_it, v_it_end) = boost::vertices(g_);
69 for (; v_it != v_it_end; ++v_it) {
70 mol2node_[mhs_[ind]] = *v_it;
71 node2mol_[*v_it] = mhs_[ind];
84 if (!boost::edge(u, v, g_).second) {
85 boost::add_edge(u, v, MTU::DGWeight(0.), g_);
89 e = boost::edge(u, v, g_).first;
90 boost::put(boost::edge_weight_t(), g_, e,
91 boost::get(boost::edge_weight_t(), g_, e) - 1);
93 void show(std::ostream &out = std::cout)
const {
95 typedef boost::graph_traits<MTU::DependencyGraph>::vertex_iterator
97 std::pair<vertex_iter, vertex_iter> vp;
98 for (vp = vertices(g_); vp.first != vp.second; ++vp.first) {
99 out << node2mol_.find(*vp.first)->second->get_name() <<
" ";
103 boost::graph_traits<MTU::DependencyGraph>::edge_iterator ei, ei_end;
104 for (boost::tie(ei, ei_end) = edges(g_); ei != ei_end; ++ei)
105 out <<
"(" << node2mol_.find(source(*ei, g_))->second->get_name() <<
","
106 << node2mol_.find(target(*ei, g_))->second->get_name() <<
","
107 << boost::get(boost::edge_weight_t(), g_, *ei) <<
")" << std::endl;
111 std::vector<MTU::DGEdge> mst;
112 boost::kruskal_minimum_spanning_tree(g_, std::back_inserter(mst));
115 for (
int i = 0; i < (int)mst.size(); i++) {
117 pp[0] = node2mol_.find(boost::source(mst[i], g_))->second;
118 pp[1] = node2mol_.find(boost::target(mst[i], g_))->second;
126 MTU::DependencyGraph g_;
128 MTU::PVMAP mol2node_;
129 MTU::VPMAP node2mol_;
132 IMPMULTIFIT_END_NAMESPACE
Utility class for building merge trees.
boost::graph DependencyGraph
A directed graph on the interactions between the various objects in the model.
A class to store an fixed array of same-typed values.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Restraint(Model *m, std::string name)
Decorator for helping deal with a hierarchy of molecules.
The standard decorator for manipulating molecular structures.
Particle * get_particle() const
Returns the particle decorated by this decorator.
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
Class to handle individual model particles.
A simple Restraint that always returns a score of zero.
virtual ModelObjectsTemp do_get_inputs() const =0
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for adding derivatives from restraints to the model.
A restraint is a term in an IMP ScoringFunction.