0% found this document useful (0 votes)
30 views3 pages

Cluster Growth Model: Eden Button 1

The document describes two classes - Eden and DLA - that model cluster growth using different algorithms. The Eden class uses a random perimeter selection method to add new occupied sites, while the DLA class uses a random walk algorithm where new sites are added to random perimeter neighbors. Both classes initialize an occupied and perimeter boolean array, update the perimeter on each step, and provide methods for seeding clusters and selecting new occupied sites.

Uploaded by

Rabbia Amin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

Cluster Growth Model: Eden Button 1

The document describes two classes - Eden and DLA - that model cluster growth using different algorithms. The Eden class uses a random perimeter selection method to add new occupied sites, while the DLA class uses a random walk algorithm where new sites are added to random perimeter neighbors. Both classes initialize an occupied and perimeter boolean array, update the perimeter on each step, and provide methods for seeding clusters and selecting new occupied sites.

Uploaded by

Rabbia Amin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Cluster Growth Model

Eden Button 1:
{
Eden objeden = new Eden();
objeden.seed();

while (true)
{
objeden.PerimeterDecide();
objeden.occupiedDecideEden(this);

DLA Button 2:
{
DLA objdla = new DLA();
objdla.seed();
Graphics gg = this.CreateGraphics();
SolidBrush sb = new SolidBrush(Color.Black);
while (true)
{

objdla.PerimeterDecide();
Point newp = objdla.occupiedDecideDLA();
gg.FillEllipse(sb, 250 + newp.X, 350 - newp.Y, 5, 5);

}
}

Eden Class:
class Eden
{
int size = 100;
Random rnd = new Random();
bool[,] occupied;
bool[,] perimeter;
public Eden()
{
occupied = new bool[size, size];
perimeter = new bool[size, size];
}
public void seed()
{
occupied[size / 2, size / 2] = true;
}
public void seed1()
{
for (int i = 0; i < size; i++)
{
occupied[i, size - 2] = true;
}
}
public void PerimeterDecide()
{
for (int i = 0; i < size - 1; i++)
{
for (int j = 0; j < size - 1; j++)
{
if (occupied[i, j] == true)
{
if (occupied[i + 1, j] == false)
perimeter[i + 1, j] = true;
if (occupied[i - 1, j] == false)
perimeter[i - 1, j] = true;
if (occupied[i, j + 1] == false)
perimeter[i, j + 1] = true;
if (occupied[i, j - 1] == false)
perimeter[i, j - 1] = true;
}
}
}
}
public void occupiedDecideEden(Form1 f1)
{
Graphics gg = f1.CreateGraphics();
SolidBrush sb = new SolidBrush(Color.Red);
// Point coordinate = new Point();
int x = rnd.Next(size);
int y = rnd.Next(size);
if (perimeter[x, y] == true)
{
occupied[x, y] = true;
gg.FillEllipse(sb, 250 + x * 3, 350 - y * 3, 5, 5);

}
}

DLA Class:
class DLA
{
int size = 300;
bool[,] occupied;
bool[,] perimeter;
public DLA()
{
occupied = new bool[size, size];
perimeter = new bool[size, size];
}
public void seed()
{
occupied[size / 2, size / 2] = true;
}
public void seed1()
{
for (int i = 0; i < size; i++)
{
occupied[i, size - 2] = true;
}
}
public void PerimeterDecide()
{
for (int i = 0; i < size - 1; i++)
{
for (int j = 0; j < size - 1; j++)
{
if (occupied[i, j] == true)
{
if (occupied[i + 1, j] == false)
perimeter[i + 1, j] = true;
if (occupied[i - 1, j] == false)
perimeter[i - 1, j] = true;
if (occupied[i, j + 1] == false)
perimeter[i, j + 1] = true;
if (occupied[i, j - 1] == false)
perimeter[i, j - 1] = true;
}
}
}
}
public Point occupiedDecideDLA()
{
Random rnd = new Random();
int x = rnd.Next(size);
int y = rnd.Next(size);
while (perimeter[x, y] == false)
{
double r = rnd.NextDouble();
if (r < 0.25 && x > 0)
x--;
else if (r >= 0.25 && r < 0.5 && x < size - 1)
x++;
else if (r >= 0.5 && r < 0.75 && y > 0)
y--;
else if (y < size - 1)
y++;
}
occupied[x, y] = true;
Point coordinates = new Point(x, y);
return coordinates;
}
}

You might also like