Browse Source

check that value is actually non-zero

Former-commit-id: e3c5ee614e848940da250528ddb8cd389efaa6f5
Alec Jacobson 8 years ago
parent
commit
fd4b24121d
1 changed files with 2 additions and 1 deletions
  1. 2 1
      include/igl/components.cpp

+ 2 - 1
include/igl/components.cpp

@@ -24,6 +24,7 @@ IGL_INLINE void igl::components(
   C.resize(n,1);
   C.resize(n,1);
   typename DerivedC::Scalar id = 0;
   typename DerivedC::Scalar id = 0;
   vector<typename Derivedcounts::Scalar> vcounts;
   vector<typename Derivedcounts::Scalar> vcounts;
+  // breadth first search
   for(int k=0; k<A.outerSize(); ++k)
   for(int k=0; k<A.outerSize(); ++k)
   {
   {
     if(seen(k))
     if(seen(k))
@@ -48,7 +49,7 @@ IGL_INLINE void igl::components(
       for(typename SparseMatrix<AScalar>::InnerIterator it (A,f); it; ++it)
       for(typename SparseMatrix<AScalar>::InnerIterator it (A,f); it; ++it)
       {
       {
         const int g = it.index();
         const int g = it.index();
-        if(!seen(g))
+        if(!seen(g) && it.value())
         {
         {
           Q.push(g);
           Q.push(g);
         }
         }