I don't see why this would prevent friendships. You don't have to be on the train 24 hours a day - just overnight while sleeping. If you have friends in Berlin you can arrive in Berlin in the morning, spend the day hanging out with them, then head back to the station at 10pm for a night train to somewhere else.
At its best this could enable you to maintain friendship groups in multiple cities.
At its best this could enable you to maintain friendship groups in multiple cities.