     if (vForceLen <= 0)
       vForceLen = EPSILON;
 
-    speed[gid] = K_S * gs / (1 + (gs * sqrt(vSwg)));
-    speed[gid] = fmin(speed[gid], (float)
+    *speed = K_S * gs / (1 + (gs * sqrt(vSwg)));
+    *speed = fmin(*speed, (float)
         K_SMAX / vForceLen);
   }
 }

}

__device__ void fa2UpdateDisplacement(unsigned int gid,
    unsigned int numvertices, float* speed, float forceX, float forceY,
    float* dispX, float* dispY)
{
  if (gid < numvertices)
  {
    *dispX = forceX;
    *dispY = forceY;
    vectorMultiply(dispX, dispY, speed[gid]);
  }
}


  fa2UpdateTract(gid, numvertices, forceX, forceY, oldForceX, oldForceY, tra);

  // Update speed of vertices.
  fa2UpdateSpeed(gid, numvertices, &speed, swg, forceX, forceY, graphSpeed);

  // Update displacement of vertices.
  fa2UpdateDisplacement(gid, numvertices, speed, forceX, forceY, &dispX, &dispY);
