public void MakeRegionMap(int[] partition, int size)
{
if (regions == null || regions.Length != size)
{
int n = regionColors.Length;
regions = new SolidBrush[size];
for (int j = 0; j < size; j++)
{
regions[j] = new SolidBrush(regionColors[j % n]);
}
}
if (regionMap == null)
{
regionMap = new Dictionary<int, int>(size);
}
else
{
regionMap.Clear();
}
int k = 0;
for (int i = 0; i < partition.Length; i++)
{
if (!regionMap.ContainsKey(partition[i]))
{
regionMap.Add(partition[i], k++);
}
}
}