#ifndef IGL_ADJACENCY_MATRIX_H #define IGL_ADJACENCY_MATRIX_H #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET #include #include namespace igl { // Constructs the graph adjacency list of a given mesh (V,F) // Templates: // T should be a eigen sparse matrix primitive type like int or double // Inputs: // F #F by dim list of mesh faces (must be triangles) // Outputs: // A vector > containing at row i the adjacent vertices of vertex i // // Example: // // Mesh in (V,F) // vector > A; // adjacency_list(F,A); // // See also: edges, cotmatrix, diag template inline void adjacency_list( const Eigen::MatrixXi & F, vector >& A ); } // Implementation #include "verbose.h" template inline void igl::adjacency_list( const Eigen::MatrixXi & F, vector >& A) { A.clear(); A.resize(F.maxCoeff()+1); // Loop over faces for(int i = 0;i d int s = F(i,j); int d = F(i,(j+1)%F.cols()); if (s>d) { A[s].push_back(d); A[d].push_back(s); } } } } #endif