File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
cpp_easygraph/functions/centrality Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -228,22 +228,22 @@ std::vector<double> compute_eigenvector_eigen(
228228 std::vector<double > result (n);
229229
230230 try {
231- Eigen::SelfAdjointEigenSolver <Eigen::MatrixXd> solver;
231+ Eigen::EigenSolver <Eigen::MatrixXd> solver;
232232
233233 if (n < 1000 ) {
234234 Eigen::MatrixXd dense_matrix (eigen_matrix);
235235 solver.compute (dense_matrix);
236236
237237 int max_idx = 0 ;
238- double max_val = solver.eigenvalues ()[0 ];
238+ double max_val = solver.eigenvalues ()[0 ]. real () ;
239239 for (int i = 1 ; i < n; i++) {
240- if (solver.eigenvalues ()[i] > max_val) {
241- max_val = solver.eigenvalues ()[i];
240+ if (solver.eigenvalues ()[i]. real () > max_val) {
241+ max_val = solver.eigenvalues ()[i]. real () ;
242242 max_idx = i;
243243 }
244244 }
245245
246- Eigen::VectorXd eigen_vec = solver.eigenvectors ().col (max_idx);
246+ Eigen::VectorXd eigen_vec = solver.eigenvectors ().col (max_idx). real () ;
247247 for (int i = 0 ; i < n; i++) {
248248 result[i] = eigen_vec (i);
249249 }
You can’t perform that action at this time.
0 commit comments