The standard genetic code (SGC) is a system of rules, which assigns 20 amino acids and stop translation signal to 64 codons, i.e triplets of nucleotides. The structure of the SGC shows some properties suggesting that this code evolved to minimize deleterious effects of mutations and translational errors. To analyse this issue, we presented the structure of the SGC and its natural alternative versions as a graph, in which vertices corresponded to codons and edges to point mutations between these codons. The mutations were weighted according to the mutation type, i.e. transitions and transversions. Under this representation, each genetic code is a partition of the set of vertices into 21 disjoint subsets, while its resistance to the mutation consequences can be reformulated into the optimal graph clustering task. In order to investigate this problem, we developed an appropriate clustering algorithm, which searched for the codes showing the minimum average calculated for the set conductance of codon groups. The algorithm found three best codes for various ranges of the weights for the mutations. The average weighted-conductance of the studied genetic codes was the most similar to that of the best codes in the range of weights corresponding to the observed transversion/transition ratio in natural mutational pressures. However, it should be noted that the optimization of the codes was not as perfect as the best codes and many alternative genetic codes performed better than the SGC. These results may suggest that the evolution of the SGC was driven not only by the selection for the robustness to mutations or mistranslations.