-
Notifications
You must be signed in to change notification settings - Fork 1
/
clustermachine.h
43 lines (34 loc) · 1016 Bytes
/
clustermachine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef CLUSTERMACHINE_H
#define CLUSTERMACHINE_H
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <forward_list>
#include "PartArray.h"
#include "StateMachineFree.h"
class ClusterMachine
{
public:
typedef vector<Part*> cluster;
typedef vector<cluster> clusterArray;
ClusterMachine(PartArray *sys, double interactionRange);
cluster max();
cluster min();
clusterArray &all();
double averageSize();
double maximalSize();
double minimalSize();
private:
PartArray *sys;
double interactionRange;
unsigned lastSize;
void initNeightbours();
bool isConnected(const Part* p1, const Part* p2) const;
bool isNeightbours(const Part* a, const Part* b) const;
unordered_map<unsigned,forward_list <Part*> > neighbours;
void findClusters();
void walkNeighbours(Part *part, cluster ¤tCluster, unordered_set<unsigned> &unWalked);
StateMachineFree oldState;
clusterArray _clusters;
};
#endif // CLUSTERMACHINE_H