RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
PartitionSet.h
Go to the documentation of this file.
1//
2// Copyright (C) David Cosgrove 2023
3//
4// @@ All Rights Reserved @@
5// This file is part of the RDKit.
6// The contents are covered by the terms of the BSD license
7// which is included in the file license.txt, found at the root
8// of the RDKit source tree.
9//
10
11#ifndef RASCALMCES_PARTITION_SET_H
12#define RASCALMCES_PARTITION_SET_H
13
14#include <map>
15#include <vector>
16
17#include <boost/dynamic_bitset.hpp>
18
19namespace RDKit {
20
21namespace RascalMCES {
22
24 public:
25 // Make a partition set from the modular product and the labels
26 // of the vertices from the first graph. Each element in vtxPairs
27 // has a row/column in modProd. The partitions are sorted
28 // into descending order of sizes.
29 PartitionSet(const std::vector<boost::dynamic_bitset<>> &modProd,
30 const std::vector<std::pair<int, int>> &vtxPairs,
31 const std::vector<unsigned int> &vtx1Labels,
32 const std::vector<unsigned int> &vtx2Labels,
33 unsigned int lowerBound);
34
35 bool isEmpty() const { return d_parts.empty(); }
36
37 size_t numParts() const { return d_parts.size(); }
38
39 // Compute the upper bound on the clique that can be extracted from
40 // the current partition.
42
43 friend std::ostream &operator<<(std::ostream &os, const PartitionSet &pt);
44
45 // removes the last element of the last partition and returns
46 // its value. Throws a runtime_error if empty.
47 unsigned int popLastVertex();
48
49 // remove from the partitions any vertex not connected to the given
50 // vertex
51 void pruneVertices(unsigned int vtx_num);
52
53 private:
54 std::shared_ptr<const std::vector<boost::dynamic_bitset<>>> d_ModProd;
55 std::shared_ptr<const std::vector<std::pair<int, int>>> d_VtxPairs;
56 std::shared_ptr<const std::vector<unsigned int>> d_vtx1Labels;
57 std::shared_ptr<const std::vector<unsigned int>> d_vtx2Labels;
58 std::vector<std::vector<unsigned int>> d_parts;
59 // counts of the number of times each vertex appears in the partitions
60 std::vector<int> d_vtx1Counts, d_vtx2Counts;
61 // counts of the number of times the d_vtx[12]_labels appear in the partitions
62 std::vector<int> d_vtx1TypeCounts, d_vtx2TypeCounts;
63
64 void sortPartitions();
65
66 void calcVtxTypeCounts();
67
68 void decrementVertexCounts(int vtxNum);
69};
70} // namespace RascalMCES
71} // namespace RDKit
72
73#endif // RASCALMCES_PARTITION_SET_H
PartitionSet(const std::vector< boost::dynamic_bitset<> > &modProd, const std::vector< std::pair< int, int > > &vtxPairs, const std::vector< unsigned int > &vtx1Labels, const std::vector< unsigned int > &vtx2Labels, unsigned int lowerBound)
void pruneVertices(unsigned int vtx_num)
friend std::ostream & operator<<(std::ostream &os, const PartitionSet &pt)
Std stuff.
bool rdvalue_is(const RDValue_cast_t)