2 #ifndef PHYLO_TYPEDEFS_HPP
3 #define PHYLO_TYPEDEFS_HPP
7 #include "graph_typedefs.hpp"
15 typedef adjacency_list<hash_setS,
18 property<vertex_index_t, size_t,
19 property<vertex_name_t, std::string>
27 typedef Vertex<InternalNet> InternVertex;
28 typedef VertexPair<InternalNet> InternVertexPair;
29 typedef VertexSet<InternalNet> InternVertexSet;
30 typedef VertexList<InternalNet> InternVertexList;
31 typedef Edge<InternalNet> Arc;
32 typedef boost::graph_traits<InternalNet>::out_edge_iterator OutEdgeIter;
33 typedef std::pair<OutEdgeIter, OutEdgeIter> OutEdgeIterRange;
34 typedef boost::graph_traits<InternalNet>::in_edge_iterator InEdgeIter;
35 typedef std::pair<InEdgeIter, InEdgeIter> InEdgeIterRange;
37 Vertex<InternalNet> root;
44 const InternVertex& get_root()
const
49 InternVertexList get_leaves()
const{
50 InternVertexList result;
51 for(VertexIterRange<InternalNet> v = boost::vertices(net); v.first != v.second; ++v.first)
52 if(boost::out_degree(*v.first, net) == 0)
53 result.push_back(*v.first);
57 std::string get_name(
const InternVertex& v)
const{
58 return boost::get(vertex_name, net, v);
61 InternVertexList get_parents(
const InternVertex& u)
const{
62 InternVertexList result;
63 for(InEdgeIterRange e = boost::in_edges(u, net); e.first != e.second; ++e.first)
64 result.push_back(boost::source(*e.first, net));
68 size_t num_vertices()
const{
69 return boost::num_vertices(net);
71 size_t num_edges()
const{
72 return boost::num_edges(net);
75 const InternalNet get_network()
const{
82 const InternVertex& set_root(
const size_t idx = 0)
86 root = boost::add_vertex(net);
88 put(vertex_index, net, root, idx);
92 const InternVertex& add_vertex(
const InternVertex& parent,
const size_t idx = 0,
const std::string& name =
"")
94 const InternVertex& v = boost::add_vertex(net);
95 boost::put(vertex_index, net, v, idx ? idx : num_vertices());
96 boost::put(vertex_name, net, v, name !=
"" ? name : std::to_string(idx));
97 boost::add_edge(parent, v, net);
101 const InternVertex& add_vertex(
const std::list<InternVertex>& parents,
const size_t idx = 0,
const std::string& name =
"")
103 const InternVertex& v = boost::add_vertex(net);
104 boost::put(vertex_index, net, v, idx ? idx : num_vertices());
105 boost::put(vertex_name, net, v, name !=
"" ? name : std::to_string(idx));
106 for(
const InternVertex& p : parents)
107 boost::add_edge(p, v, net);
111 void make_leaf(
const InternVertex& v,
const std::string& name){
112 boost::put(vertex_name, net, v, name);
115 void add_arc(
const InternVertexPair& e){
116 boost::add_edge(e.first, e.second, net);
118 void add_arc(
const InternVertex& u,
const InternVertex& v){
119 boost::add_edge(u, v, net);
122 void delete_vertex(
const InternVertex& v){
123 boost::clear_vertex(v, net);
124 boost::remove_vertex(v, net);
Definition: graph_utils.hpp:18
Definition: phylo_typedefs.hpp:13
Definition: read_phytree.hpp:10