TrialMatrix[n_,d_]:=Table[Sum[,{k,d}],{i,n},{j,n}]
2
(x[i,k]-x[j,k])
Clear[FindEmbedding]
FindEmbedding[g_,d_:2,wf_:(1&),s_:1234,opts___]:=Module[{i,n=Length[g]},m=DistanceMatrix[g];c=Apply[Plus,Flatten[Map[wf,m,{2}](TrialMatrix[n,d]-m^2)]^2];vars=Flatten[Table[x[i,j],{i,2,n},{j,d}]];con=Table[x[1,i]->0,{i,d}];SeedRandom[s];ans=FindMinimum[Evaluate[c/.con],##,opts]&@@({#,Random[]}&/@vars);ans2=Prepend[Partition[vars/.Last[ans],d],Table[0,{d}]];ans3=Map[ans2[[#]]&,NodesToEdges[g],{-1}];{ans2,If[d==2,Graphics,Graphics3D][Line/@ans3,AspectRatio->Automatic]}]
EmbeddedMatrix[data_]:=Sqrt[Outer[Apply[Plus,(#1-#2)^2]&,data,data,1]]
FindEmbedding[tetra];
Show[Last[%]];
EmbeddedMatrix[First[%129]]
{{0,0.816553,1.15465,0.816043},{0.816553,0.,0.816933,1.15482},{1.15465,0.816933,0.,0.81655},{0.816043,1.15482,0.81655,0.}}
Show[FindEmbedding[tetra,3]];
FindEmbedding[dodec1];
FindMinimum::fmcv:Failed to converge to the requested accuracy or precision within 30 iterations.
Show[Last[%]];
EmbeddedMatrix[First[%%]]
Round[%]
{{0,1,1,1,1,3,2,3,2,0,4,4,4,4,4,3,2,2,3,4},{1,0,0,2,2,4,3,2,1,1,4,4,3,3,4,4,3,1,2,4},{1,0,0,2,2,3,3,2,1,1,4,4,3,3,4,4,3,1,2,3},{1,2,2,0,0,2,1,3,3,1,3,3,4,4,4,2,1,3,4,3},{1,2,2,0,0,2,1,4,3,1,3,3,4,4,4,2,1,3,4,4},{3,4,3,2,2,0,1,3,4,3,1,1,3,3,2,0,1,4,4,2},{2,3,3,1,1,1,0,4,4,2,2,2,4,4,3,1,0,4,4,3},{3,2,2,3,4,3,4,0,1,3,3,3,1,1,2,4,4,1,0,2},{2,1,1,3,3,4,4,1,0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