Graham's scan starts with 25 random points, and then computes their convex hull.

The algorithm works in three phases:

  1. Find an extreme point. This point will be the pivot, is guaranteed to be on the hull, and is chosen to be the point with smallest y coordinate.
  2. Sort the points in order of increasing angle about the pivot. We end up with a star-shaped polygon (one in which one special point, in this case the pivot, can "see" the whole polygon).
  3. Build the hull, by marching around the star-shaped poly, adding edges when we make a left turn, and back-tracking when we make a right turn.
You need a browser that understands java to view this applet. Otherwise, you will only see this message.