Gravity and the structure of noncommutative algebras