Exemple #1
0
 /// <summary>
 /// Remembers the PRACluster as a Neighbor. If it already is a neighbor, returns and does nothing.
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 internal void AddNeighbor(int key, PRAClusterNode value)
 {
     if (!neighbors.ContainsKey(key) && key != this.ID)
     {
         neighbors.Add(key, value);
         calculateHDist(value);
     }
 }
Exemple #2
0
        internal void calculateHDist(PRAClusterNode neighbor)
        {
            //sqrt(2) * min( abs(dx), abs(dy) ) + (abs(dx) - abs(dy))
            if (!neighborDist.ContainsKey(neighbor.ID))
            {
                int dx = Math.Abs(this.X - neighbor.X);
                int dy = Math.Abs(this.Y - neighbor.Y);

                float dist = 1.4f * Math.Min(dx, dy) + Math.Abs(dx - dy);

                //add if doesnt exist
                if (!this.neighborDist.ContainsKey(neighbor.ID))
                {
                    this.neighborDist.Add(neighbor.ID, dist);
                }
                else //update value
                {
                    this.neighborDist[neighbor.ID] = dist;
                }
            }
        }
 public void AddClusterNode(PRAClusterNode node)
 {
     this.ClusterNodes.Add(node.ID, node);
 }