Simplified graph density calculation.