/** * \file JunctionTree.h * \brief Stores a junction tree * * Copyright 2007-2010 IMP Inventors. All rights reserved. * */ #ifndef IMPDOMINO_JUNCTION_TREE_H #define IMPDOMINO_JUNCTION_TREE_H #include "domino_config.h" #include "IMP/base_types.h" #include #include #include #include IMPDOMINO_BEGIN_NAMESPACE //! Stores a junction tree /** \note A junction tree T of an arbitrary graph G is a tree decomposition that has these three properties: 1. singly connected: there is exactly one path between each pair of subsets. 2. covering: for each clique A of G there is some subset C such that A ⊆ C. 3. running intersection: for each pair of clusters B and C that contain i, each cluster on the unique path between B and C also contains i. Further reading: Jordan (1999) Learning in graphical models */ class IMPDOMINOEXPORT JunctionTree { public: typedef boost::adjacency_list Graph; JunctionTree() {} JunctionTree(int number_of_nodes) { set_nodes(number_of_nodes); } //! Initialize a graph with N nodes void set_nodes(int number_of_nodes); void add_edge(int v1,int v2) { IMP_INTERNAL_CHECK(static_cast(v1) < boost::num_vertices(g_), "input node index (" << v1 << ") is out of range (" << boost::num_vertices(g_) << std::endl); IMP_INTERNAL_CHECK(static_cast(v2) < boost::num_vertices(g_), "input node index (" << v2 << ") is out of range (" << boost::num_vertices(g_) << std::endl); boost::add_edge(v1,v2,g_); } void set_node_name(int vi, const std::string &name) { IMP_USAGE_CHECK(static_cast(vi) < boost::num_vertices(g_), "input node index (" << vi << ") is out of range (" << boost::num_vertices(g_) << ")"<::edge_descriptor e; boost::tie(e, found) = boost::edge(boost::vertex(n1,g_), boost::vertex(n2,g_), g_); return found; } void show(std::ostream& out = std::cout) const; protected: typedef std::vector > NodeData; Graph g_; NodeData data_; }; IMPDOMINOEXPORT void read_junction_tree( const std::string &filename, JunctionTree *jt); IMPDOMINO_END_NAMESPACE #endif /* IMPDOMINO_JUNCTION_TREE_H */