public static String toConnectionMapCsv(NetworkGraph graph) {
        if (graph == null) {
            throw new IllegalArgumentException("The argument may not be null.");
        }

        String output = CONNECTION_MAP_PREAMBLE;

        List<Spring> springs = graph.getSprings();
        Collections.sort(springs);

        for (Spring spring : springs) {
            Mass firstColumn = spring.getMassWithHigherIndex();
            Mass secondColumn = spring.getMassWithLowerIndex();

            output += firstColumn.getIndex(graph) + SEPARATOR
                    + secondColumn.getIndex(graph) + SEPARATOR
                    + spring.getConnectionType() + NEWLINE;
        }

        return output;
    }