3 #ifndef PHYLO_UTILS_HPP
4 #define PHYLO_UTILS_HPP
7 #include "phylo_typedefs.hpp"
15 void merge_leaves_by_name(PhyloNet& N){
16 typedef typename boost::unordered_map<std::string, PhyloNet::InternVertex> Name_to_Vertex_Map;
17 Name_to_Vertex_Map name_to_vertex;
20 PhyloNet::InternVertexList leaves = N.get_leaves();
22 for(
const auto& l : leaves){
23 const std::string lname = N.get_name(l);
25 Name_to_Vertex_Map::const_iterator i = name_to_vertex.find(lname);
26 if(i == name_to_vertex.end()){
28 name_to_vertex.insert(i, Name_to_Vertex_Map::value_type(lname, l));
31 const PhyloNet::InternVertex cur_l = i->second;
32 PhyloNet::InternVertex parent = *(N.get_parents(l).begin());
34 N.add_arc(parent, cur_l);
Definition: graph_utils.hpp:18
Definition: read_phytree.hpp:10