One embodiment of the present invention provides a system that computes
feature density for a number of areas within a layout by moving a window
across the layout, which allows the system to identify areas in the
layout that violate a design rule. During operation, the system receives
a layout. Next, the system places the window at a first location in the
layout. The system then computes the feature density value based on the
features within the window at the first location. Next, the system
determines a second location in the layout based on the first location
and the feature density value. The system then moves the window to the
second location. Next, the system computes the feature density value
based on the features within the window at the second location. Note that
determining the second location in the layout based on the feature
density value computed at the first location instead of using a constant
displacement from the first location allows the system to accurately
identify an area that violates the design rule.