30 #include <igraph/igraph.h>
38 Result<std::monostate> recover_branches_for_root(
const ClockTree &clock_tree,
39 const std::pair<const void *, PtrType> node,
41 std::vector<Branch> &branches )
43 branch.push_back( node );
45 const auto children = clock_tree.get_neighbors( node.first, IGRAPH_OUT );
46 if( children.is_error() )
48 return ERR( children.get_error().get() );
51 if( children.get().empty() )
53 branches.push_back( branch );
57 for(
const auto &child : children.get() )
60 if( std::find( branch.begin(), branch.end(), child ) != branch.end() )
65 const auto res = recover_branches_for_root( clock_tree, child, branch, branches );
68 return ERR( res.get_error().get() );
81 std::vector<Branch> branches;
83 for(
const igraph_int_t root : clock_tree.
get_roots() )
86 if( root_ptr.is_error() )
88 return ERR( root_ptr.get_error().get() );
91 const auto result = recover_branches_for_root( clock_tree, root_ptr.get(), branch, branches );
92 if( result.is_error() )
94 return ERR( result.get_error().get() );
98 return OK( std::move( branches ) );
const std::unordered_set< igraph_int_t > & get_roots() const
Result< std::pair< const void *, PtrType > > get_ptr_from_vertex(igraph_int_t vertex) const
Result< std::vector< Branch > > recover_branches(const ClockTree &clock_tree)
std::vector< std::pair< const void *, PtrType > > Branch