Chemical Data Processing Library C++ API - Version 1.4.0
BronKerboschAlgorithm.hpp
Go to the documentation of this file.
1 /*
2  * BronKerboschAlgorithm.hpp
3  *
4  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
27 #ifndef CDPL_UTIL_BRONKERBOSCHALGORITHM_HPP
28 #define CDPL_UTIL_BRONKERBOSCHALGORITHM_HPP
29 
30 #include <cstddef>
31 #include <vector>
32 
33 #include "CDPL/Util/APIPrefix.hpp"
34 #include "CDPL/Util/BitSet.hpp"
35 #include "CDPL/Util/Array.hpp"
37 
38 
39 namespace CDPL
40 {
41 
42  namespace Util
43  {
44 
49  {
50 
51  public:
56 
62 
68 
73  void init(const BitSetArray& adj_mtx);
74 
80  bool nextClique(BitSet& clique);
81 
88 
89  private:
90  struct State
91  {
92 
93  BitSet curr;
94  BitSet pool;
95  BitSet excl;
96  std::size_t u;
97  std::size_t v;
98  };
99 
100  typedef std::vector<std::size_t> NodeDegreeTable;
101  typedef std::vector<State*> StateStack;
102  typedef Util::ObjectStack<State> StateCache;
103 
104  const BitSetArray* adjMatrix;
105  StateCache stateCache;
106  NodeDegreeTable nodeDegrees;
107  StateStack states;
108  BitSet pivotCandSet;
109  };
110  } // namespace Util
111 } // namespace CDPL
112 
113 #endif // CDPL_UTIL_BRONKERBOSCHALGORITHM_HPP
Definition of class CDPL::Util::Array.
Declaration of type CDPL::Util::BitSet.
Definition of class CDPL::Util::ObjectStack.
Definition of the preprocessor macro CDPL_UTIL_API.
#define CDPL_UTIL_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Implementation of the Bron-Kerbosch clique-detection algorithm [BKA].
Definition: BronKerboschAlgorithm.hpp:49
void init(const BitSetArray &adj_mtx)
(Re-)initializes the algorithm with the adjacency matrix adj_mtx and resets the clique iterator.
BronKerboschAlgorithm()
Constructs the BronKerboschAlgorithm instance without an associated adjacency matrix.
Definition: BronKerboschAlgorithm.hpp:55
bool nextClique(BitSet &clique)
Advances the clique iterator and writes the next maximal clique into clique.
BronKerboschAlgorithm(const BitSetArray &adj_mtx)
Constructs the BronKerboschAlgorithm instance and immediately initializes it with the adjacency matri...
BronKerboschAlgorithm(const BronKerboschAlgorithm &bka)
Constructs a copy of the BronKerboschAlgorithm instance bka.
BronKerboschAlgorithm & operator=(const BronKerboschAlgorithm &bka)
Copy assignment operator.
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
Array< BitSet > BitSetArray
Array storing Util::BitSet objects.
Definition: Array.hpp:605
The namespace of the Chemical Data Processing Library.