18#include <Eigen/Sparse>
25template <
typename DerivedA,
typename DerivedC,
typename Derivedcounts>
26void vertex_components(
27 const Eigen::SparseCompressedBase<DerivedA>& A,
28 Eigen::PlainObjectBase<DerivedC>& C,
29 Eigen::PlainObjectBase<Derivedcounts>& counts)
31 assert(A.rows() == A.cols() &&
"A should be square.");
32 const size_t n = A.rows();
33 Eigen::Array<bool, Eigen::Dynamic, 1> seen = Eigen::Array<bool, Eigen::Dynamic, 1>::Zero(n, 1);
35 typename DerivedC::Scalar
id = 0;
36 std::vector<typename Derivedcounts::Scalar> vcounts;
38 for (
int k = 0; k < A.outerSize(); ++k) {
46 const int f = Q.front();
55 for (
typename DerivedA::InnerIterator it(A, f); it; ++it) {
56 const int g = it.index();
57 if (!seen(g) && it.value()) {
64 assert((
size_t)
id == vcounts.size());
65 const size_t ncc = vcounts.size();
66 assert((
size_t)C.maxCoeff() + 1 == ncc);
67 counts.resize(ncc, 1);
68 for (
size_t i = 0; i < ncc; i++) {
69 counts(i) = vcounts[i];
73template <
typename DerivedA,
typename DerivedC>
74void vertex_components(
75 const Eigen::SparseCompressedBase<DerivedA>& A,
76 Eigen::PlainObjectBase<DerivedC>& C)
78 Eigen::VectorXi counts;
79 return vertex_components(A, C, counts);
nullptr_t, size_t, ptrdiff_t basic_ostream bad_weak_ptr extent, remove_extent, is_array,...
Definition: attribute_string_utils.h:21