7 #ifndef IMPMULTIFIT_MERGE_TREE_UTILS_H
8 #define IMPMULTIFIT_MERGE_TREE_UTILS_H
10 #include <boost/functional/hash.hpp>
11 #include <boost/graph/adjacency_matrix.hpp>
12 #include <boost/graph/adjacency_list.hpp>
13 #include <boost/pending/disjoint_sets.hpp>
14 #include <boost/graph/graph_utility.hpp>
15 #include <IMP/multifit/multifit_config.h>
17 #include <boost/unordered_map.hpp>
18 #include <boost/graph/kruskal_min_spanning_tree.hpp>
19 #include <boost/graph/prim_minimum_spanning_tree.hpp>
21 IMPMULTIFIT_BEGIN_NAMESPACE
24 typedef boost::adjacency_matrix<boost::undirectedS, boost::no_property,
25 boost::property<boost::edge_weight_t, double> >
27 typedef boost::graph_traits<DependencyGraph>::edge_descriptor DGEdge;
28 typedef DependencyGraph::edge_property_type DGWeight;
29 typedef boost::graph_traits<DependencyGraph>::vertex_descriptor DGVertex;
30 typedef boost::unordered_map<kernel::Particle *, DGVertex> PVMAP;
31 typedef boost::unordered_map<DGVertex, Particle *> VPMAP;
56 typedef boost::graph_traits<MTU::DependencyGraph>::vertex_iterator
58 VertexIterator v_it, v_it_end;
59 boost::tie(v_it, v_it_end) = boost::vertices(g_);
61 for (; v_it != v_it_end; ++v_it) {
62 mol2node_[mhs_[ind]] = *v_it;
63 node2mol_[*v_it] = mhs_[ind];
76 if (!boost::edge(u, v, g_).second) {
77 boost::add_edge(u, v, MTU::DGWeight(0.), g_);
81 e = boost::edge(u, v, g_).first;
82 boost::put(boost::edge_weight_t(), g_, e,
83 boost::get(boost::edge_weight_t(), g_, e) - 1);
85 void show(std::ostream &out = std::cout)
const {
87 typedef boost::graph_traits<MTU::DependencyGraph>::vertex_iterator
89 std::pair<vertex_iter, vertex_iter> vp;
90 for (vp = vertices(g_); vp.first != vp.second; ++vp.first) {
91 out << node2mol_.find(*vp.first)->second->get_name() <<
" ";
95 boost::graph_traits<MTU::DependencyGraph>::edge_iterator ei, ei_end;
96 for (boost::tie(ei, ei_end) = edges(g_); ei != ei_end; ++ei)
97 out <<
"(" << node2mol_.find(source(*ei, g_))->second->get_name() <<
","
98 << node2mol_.find(target(*ei, g_))->second->get_name() <<
","
99 << boost::get(boost::edge_weight_t(), g_, *ei) <<
")" << std::endl;
103 std::vector<MTU::DGEdge> mst;
104 boost::kruskal_minimum_spanning_tree(g_, std::back_inserter(mst));
107 for (
int i = 0; i < (int)mst.size(); i++) {
109 pp[0] = node2mol_.find(boost::source(mst[i], g_))->second;
110 pp[1] = node2mol_.find(boost::target(mst[i], g_))->second;
118 MTU::DependencyGraph g_;
120 MTU::PVMAP mol2node_;
121 MTU::VPMAP node2mol_;
124 IMPMULTIFIT_END_NAMESPACE
boost::graph DependencyGraph
A directed graph on the interactions between the various objects in the model.
Class for adding derivatives from restraints to the model.
Particle * get_particle() const
Returns the particle decorated by this decorator.
Utility class for building merge trees.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
A class to store an fixed array of same-typed values.
Decorator for helping deal with a hierarchy of molecules.
The standard decorator for manipulating molecular structures.
A restraint is a term in an IMP ScoringFunction.
Class to handle individual model particles.
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
virtual ModelObjectsTemp do_get_inputs() const =0
IMP::kernel::Restraint Restraint
A simple Restraint that always returns a score of zero.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.