As close as you want. The photo below is a good example of hives close together. This is actually a mobile bee house in Slovenia that can be moved from field to field. Here in the United States migratory beekeepers place whole pallets of bees in fields and orchards. The bees manage to find their way back home.
However, it is said that bees tend to “drift” to the hives on the end, so that after a while, the end hives have more bees than the middle hives. I have never noticed it in my own hives, which are three to a hive stand, so I don’t actually know how much of an issue it is.