Moved the building of the topology into a static method