#include "dfs.h" #include "list_to_matrix.h" #include template < typename AType, typename DerivedD, typename DerivedP, typename DerivedC> IGL_INLINE void igl::dfs( const std::vector > & A, const size_t s, Eigen::PlainObjectBase & D, Eigen::PlainObjectBase & P, Eigen::PlainObjectBase & C) { std::vector vD; std::vector vP; std::vector vC; dfs(A,s,vD,vP,vC); list_to_matrix(vD,D); list_to_matrix(vP,P); list_to_matrix(vC,C); } template < typename AType, typename DType, typename PType, typename CType> IGL_INLINE void igl::dfs( const std::vector > & A, const size_t s, std::vector & D, std::vector & P, std::vector & C) { // number of nodes int N = s+1; for(const auto & Ai : A) for(const auto & a : Ai) N = std::max(N,a+1); std::vector seen(N,false); P.resize(N,-1); std::function dfs_helper; dfs_helper = [&D,&P,&C,&dfs_helper,&seen,&A](const size_t s, const size_t p) { if(seen[s]) return; seen[s] = true; D.push_back(s); P[s] = p; for(const auto n : A[s]) dfs_helper(n,s); C.push_back(s); }; dfs_helper(s,-1); } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation // generated by autoexplicit.sh template void igl::dfs, Eigen::Matrix, Eigen::Matrix >(std::vector >, std::allocator > > > const&, const size_t, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif