|
1 | 1 | /* |
2 | 2 | * This file is part of the GreasePad distribution (https://github.com/FraunhoferIOSB/GreasePad). |
3 | | - * Copyright (c) 2022-2025 Jochen Meidow, Fraunhofer IOSB |
| 3 | + * Copyright (c) 2022-2026 Jochen Meidow, Fraunhofer IOSB |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
|
20 | 20 | #define CONNCOMP_H |
21 | 21 |
|
22 | 22 | #include <Eigen/Core> |
23 | | -#include <Eigen/Dense> |
24 | 23 | #include <Eigen/SparseCore> |
25 | 24 |
|
26 | | -#include "matrix.h" |
27 | | - |
28 | 25 |
|
29 | 26 | //! Sparse incidence matrix and connected components |
30 | 27 | namespace Graph { |
31 | 28 |
|
32 | 29 | using Eigen::SparseMatrix; |
33 | 30 | using Eigen::ColMajor; |
34 | 31 | using Eigen::Index; |
35 | | -using Eigen::Matrix; |
36 | 32 | using Eigen::Dynamic; |
37 | 33 | using Eigen::VectorXi; |
38 | | -using Eigen::VectorXidx; |
| 34 | +using Eigen::Vector; |
39 | 35 |
|
40 | 36 |
|
| 37 | +//! Matlab's bins = conncomp( AA, 'outputForm', 'vector') |
41 | 38 | [[nodiscard,maybe_unused]] static VectorXi conncomp(const SparseMatrix<int, ColMajor> &AA) |
42 | 39 | { |
43 | 40 |
|
44 | 41 | static VectorXi m_comp; // index vector components, 0-based |
45 | | - static Eigen::Vector<bool,Dynamic> m_visited; // for each vertex: visited? |
| 42 | + static Vector<bool,Dynamic> m_visited; // for each vertex: visited? |
46 | 43 |
|
47 | 44 | struct s { |
48 | 45 | static void depthFirstSearch( const SparseMatrix<int,ColMajor> & CC, int c, Index v) |
@@ -73,29 +70,6 @@ using Eigen::VectorXidx; |
73 | 70 | } |
74 | 71 |
|
75 | 72 |
|
76 | | -/* Connected components (vector with indices/labels) |
77 | | -class ConnComp |
78 | | -{ |
79 | | -public: |
80 | | - explicit ConnComp( const SparseMatrix<int, ColMajor> & BB); //!< Value constructor with sparse matrix |
81 | | -
|
82 | | - // [[nodiscard]] VectorXidx mapHead( int cc, Index n) const; //!< Get linear indices of the elements in 1...n with label 'cc'. |
83 | | - // [[nodiscard]] VectorXidx mapTail(int cc, Index n) const; //!< Get linear indices of the elements in n-1...end with label 'cc'. |
84 | | - [[nodiscard]] int label( Index i) const; //!< Get label/index of i-th element |
85 | | - [[nodiscard]] VectorXi head( Index n) const; //!< Get labels/indices of first n elements |
86 | | - [[nodiscard]] VectorXi tail( Index n) const; //!< Get labels/indices of last n elements |
87 | | -
|
88 | | - //! Get number of connected components |
89 | | - [[nodiscard]] int number() const { return m_comp.size()>0 ? m_comp.maxCoeff()+1 : 0; } |
90 | | -
|
91 | | -private: |
92 | | - void dfs( const SparseMatrix<int,ColMajor> & CC, |
93 | | - int c, Index v); |
94 | | -
|
95 | | - VectorXi m_comp; // index vector components, 0-based |
96 | | - Matrix<bool,Dynamic,1> m_visited; // for each vertex: visited? |
97 | | -};*/ |
98 | | - |
99 | 73 | } // namespace Graph |
100 | 74 |
|
101 | 75 | #endif // CONNCOMP_H |
0 commit comments