7 #ifndef IMPMULTIFIT_MERGE_TREE_UTILS_H
8 #define IMPMULTIFIT_MERGE_TREE_UTILS_H
10 #include <boost/graph/adjacency_matrix.hpp>
11 #include <boost/graph/adjacency_list.hpp>
12 #include <boost/pending/disjoint_sets.hpp>
13 #include <boost/graph/graph_utility.hpp>
14 #include <IMP/multifit/multifit_config.h>
16 #include <boost/unordered_map.hpp>
17 #include <boost/graph/kruskal_min_spanning_tree.hpp>
18 #include <boost/graph/prim_minimum_spanning_tree.hpp>
20 IMPMULTIFIT_BEGIN_NAMESPACE
23 typedef boost::adjacency_matrix<boost::undirectedS, boost::no_property,
24 boost::property<boost::edge_weight_t, double> >
26 typedef boost::graph_traits<DependencyGraph>::edge_descriptor DGEdge;
27 typedef DependencyGraph::edge_property_type DGWeight;
28 typedef boost::graph_traits<DependencyGraph>::vertex_descriptor DGVertex;
29 typedef boost::unordered_map<kernel::Particle *, DGVertex> PVMAP;
30 typedef boost::unordered_map<DGVertex, Particle *> VPMAP;
55 typedef boost::graph_traits<MTU::DependencyGraph>::vertex_iterator
57 VertexIterator v_it, v_it_end;
58 boost::tie(v_it, v_it_end) = boost::vertices(g_);
60 for (; v_it != v_it_end; ++v_it) {
61 mol2node_[mhs_[ind]] = *v_it;
62 node2mol_[*v_it] = mhs_[ind];
75 if (!boost::edge(u, v, g_).second) {
76 boost::add_edge(u, v, MTU::DGWeight(0.), g_);
80 e = boost::edge(u, v, g_).first;
81 boost::put(boost::edge_weight_t(), g_, e,
82 boost::get(boost::edge_weight_t(), g_, e) - 1);
84 void show(std::ostream &out = std::cout)
const {
86 typedef boost::graph_traits<MTU::DependencyGraph>::vertex_iterator
88 std::pair<vertex_iter, vertex_iter> vp;
89 for (vp = vertices(g_); vp.first != vp.second; ++vp.first) {
90 out << node2mol_.find(*vp.first)->second->get_name() <<
" ";
94 boost::graph_traits<MTU::DependencyGraph>::edge_iterator ei, ei_end;
95 for (boost::tie(ei, ei_end) = edges(g_); ei != ei_end; ++ei)
96 out <<
"(" << node2mol_.find(source(*ei, g_))->second->get_name() <<
","
97 << node2mol_.find(target(*ei, g_))->second->get_name() <<
","
98 << boost::get(boost::edge_weight_t(), g_, *ei) <<
")" << std::endl;
102 std::vector<MTU::DGEdge> mst;
103 boost::kruskal_minimum_spanning_tree(g_, std::back_inserter(mst));
106 for (
int i = 0; i < (int)mst.size(); i++) {
108 pp[0] = node2mol_.find(boost::source(mst[i], g_))->second;
109 pp[1] = node2mol_.find(boost::target(mst[i], g_))->second;
117 MTU::DependencyGraph g_;
119 MTU::PVMAP mol2node_;
120 MTU::VPMAP node2mol_;
123 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.