Commit 45485050 authored by Sergey Kireev's avatar Sergey Kireev
Browse files

get_groups_statistics implemented

parent 67c2fb3a
......@@ -522,7 +522,7 @@ int CA2D<State,hood_type>::find_groups_hex(std::function<bool(const State &)> ma
groupsize[label] = sum;
k += dk;
}
{ const int ix = nx-1; // сцепленные группы отцепляются в направлении 1-4 при переходе через вертикальную границу
{ const int ix = nx-1;
for (int iy=0;iy<ny-1;iy++)
if (match(get(ix,iy))) {
XY n1(ix,iy); hood.move(n1,4); hood.fix(n1,nx,ny);
......@@ -624,5 +624,25 @@ int CA2D<State,hood_type>::find_groups_hex(std::function<bool(const State &)> ma
return k;
}
template<class State,Neighborhood_type hood_type>
CA2D<State,hood_type>::GroupStatistics CA2D<State,hood_type>::get_groups_statistics(int threshold) {
int grpSizeThreshold = threshold;
int grpCount = 0;
int grpMinSize = nx*ny;
int grpMidSize = 0;
int grpMaxSize = 0;
for (int i=0;i<group_labels_upper_bound;i++) {
const int size = groupsize[i];
if (size > 0 && size > threshold) {
grpCount++;
grpMinSize = std::min(grpMinSize,size);
grpMaxSize = std::max(grpMaxSize,size);
grpMidSize += size;
}
}
grpMidSize /= grpCount;
return { threshold, grpCount, grpMinSize, grpMidSize, grpMaxSize };
}
} // namespace ca2d
......@@ -171,6 +171,14 @@ private:
public:
struct GroupStatistics {
int grpSizeThreshold;
int grpCount;
int grpMinSize;
int grpMidSize;
int grpMaxSize;
};
const int nx,ny;
const int groups_max;
......@@ -226,6 +234,8 @@ public:
return find_groups_sqr4(match);
}
GroupStatistics get_groups_statistics(int minsize=0);
//void save_char(const std::string &fn,int it=-1,const std::string &ext="") const;
void print_fraction(const std::vector<State> &states,const std::vector<std::string> &names) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment