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

        String output = MASSES_PREAMBLE;

        for (int i = 0; i < graph.getMasses().size(); i++) {
            Mass currentMass = graph.getMasses().get(i);

            output += currentMass.getType().getCsvValue();

            output += SEPARATOR + currentMass.x
                    + SEPARATOR + currentMass.y
                    + SEPARATOR + Z_AXIS_VALUE
                    + getConnectionsToPriorMasses(currentMass, graph);

            output += NEWLINE;
        }

        return output;
    }