// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2020 Alec Jacobson // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "connected_components.h" #include template < typename Atype, typename DerivedC, typename DerivedK> IGL_INLINE int igl::connected_components( const Eigen::SparseMatrix & A, Eigen::PlainObjectBase & C, Eigen::PlainObjectBase & K) { typedef typename Eigen::SparseMatrix::Index Index; const auto m = A.rows(); assert(A.cols() == A.rows() && "A should be square"); // 1.1 sec // m means not yet visited C.setConstant(m,1,m); // Could use amortized dynamic array but didn't see real win. K.setZero(m,1); typename DerivedC::Scalar c = 0; for(Eigen::Index f = 0;f Q; Q.push(f); while(!Q.empty()) { const Index g = Q.front(); Q.pop(); // already seen if(C(g)::InnerIterator it (A,g); it; ++it) { const Index n = it.index(); // already seen if(C(n), Eigen::Matrix >(Eigen::SparseMatrix const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); // generated by autoexplicit.sh template int igl::connected_components, Eigen::Matrix >(Eigen::SparseMatrix const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif