Skip to content

Commit 654f08e

Browse files
committed
revision file conncomp.h
1 parent ddacb27 commit 654f08e

File tree

1 file changed

+4
-30
lines changed

1 file changed

+4
-30
lines changed

src/conncomp.h

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* 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
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -20,29 +20,26 @@
2020
#define CONNCOMP_H
2121

2222
#include <Eigen/Core>
23-
#include <Eigen/Dense>
2423
#include <Eigen/SparseCore>
2524

26-
#include "matrix.h"
27-
2825

2926
//! Sparse incidence matrix and connected components
3027
namespace Graph {
3128

3229
using Eigen::SparseMatrix;
3330
using Eigen::ColMajor;
3431
using Eigen::Index;
35-
using Eigen::Matrix;
3632
using Eigen::Dynamic;
3733
using Eigen::VectorXi;
38-
using Eigen::VectorXidx;
34+
using Eigen::Vector;
3935

4036

37+
//! Matlab's bins = conncomp( AA, 'outputForm', 'vector')
4138
[[nodiscard,maybe_unused]] static VectorXi conncomp(const SparseMatrix<int, ColMajor> &AA)
4239
{
4340

4441
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?
4643

4744
struct s {
4845
static void depthFirstSearch( const SparseMatrix<int,ColMajor> & CC, int c, Index v)
@@ -73,29 +70,6 @@ using Eigen::VectorXidx;
7370
}
7471

7572

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-
9973
} // namespace Graph
10074

10175
#endif // CONNCOMP_H

0 commit comments

Comments
 (0)