I written some code to generate all partens of $\ \mathrm{C_2H_5O}$, but theres some isomerisms need to be deleted.
Here's the raw output after DeleteDuplicates
.
(*del=DeleteDuplicates@raw*)
del={{{"C",2}<->{"C",1},{"O",1}<->{"C",2},{"H",1}<->{"C",1},{"H",2}<->{"C",2},{"H",3}<->{"C",1},{"O",1}<->{"C",2},{"H",4}<->{"C",1}},{{"C",2}<->{"C",1},{"O",1}<->{"C",2},{"H",1}<->{"C",1},{"H",2}<->{"C",2},{"C",1}<->{"O",1},{"H",3}<->{"C",2},{"H",4}<->{"C",1}},{{"C",2}<->{"C",1},{"O",1}<->{"C",2},{"H",1}<->{"C",1},{"C",2}<->{"C",1},{"H",2}<->{"O",1},{"H",3}<->{"C",2},{"H",4}<->{"C",1}},{{"C",2}<->{"C",1},{"H",1}<->{"C",2},{"O",1}<->{"C",1},{"H",2}<->{"C",2},{"H",3}<->{"C",1},{"O",1}<->{"C",2},{"H",4}<->{"C",1}},{{"C",2}<->{"C",1},{"H",1}<->{"C",2},{"O",1}<->{"C",1},{"H",2}<->{"C",2},{"C",1}<->{"O",1},{"H",3}<->{"C",2},{"H",4}<->{"C",1}},{{"C",2}<->{"C",1},{"H",1}<->{"C",2},{"O",1}<->{"C",1},{"C",2}<->{"C",1},{"H",2}<->{"O",1},{"H",3}<->{"C",2},{"H",4}<->{"C",1}},{{"C",2}<->{"C",1},{"H",1}<->{"C",2},{"H",2}<->{"C",1},{"O",1}<->{"C",2},{"H",3}<->{"C",1},{"O",1}<->{"C",2},{"H",4}<->{"C",1}},{{"C",2}<->{"C",1},{"H",1}<->{"C",2},{"H",2}<->{"C",1},{"O",1}<->{"C",2},{"C",1}<->{"O",1},{"H",3}<->{"C",2},{"H",4}<->{"C",1}},{{"C",2}<->{"C",1},{"H",1}<->{"C",2},{"H",2}<->{"C",1},{"H",3}<->{"C",2},{"C",1}<->{"C",2},{"O",1}<->{"C",1},{"H",4}<->{"O",1}},{{"C",2}<->{"C",1},{"H",1}<->{"C",2},{"H",2}<->{"C",1},{"H",3}<->{"C",2},{"O",1}<->{"C",1},{"O",1}<->{"C",1},{"H",4}<->{"C",2}},{{"C",2}<->{"C",1},{"H",1}<->{"C",2},{"H",2}<->{"C",1},{"C",2}<->{"C",1},{"O",1}<->{"C",2},{"H",3}<->{"O",1},{"H",4}<->{"C",1}},{{"C",2}<->{"C",1},{"O",1}<->{"C",2},{"O",1}<->{"C",2},{"H",1}<->{"C",1},{"H",2}<->{"C",1},{"H",3}<->{"C",2},{"H",4}<->{"C",1}},{{"O",1}<->{"C",1},{"H",1}<->{"C",1},{"H",2}<->{"C",1},{"C",2}<->{"O",1},{"H",3}<->{"C",2},{"C",2}<->{"C",1},{"H",4}<->{"C",2}},{{"O",1}<->{"C",1},{"H",1}<->{"C",1},{"C",1}<->{"O",1},{"C",2}<->{"C",1},{"H",2}<->{"C",2},{"H",3}<->{"C",2},{"H",4}<->{"C",2}},{{"O",1}<->{"C",1},{"H",1}<->{"C",1},{"C",2}<->{"C",1},{"C",2}<->{"C",1},{"H",2}<->{"C",2},{"H",3}<->{"O",1},{"H",4}<->{"C",2}},{{"H",1}<->{"C",1},{"C",2}<->{"C",1},{"H",2}<->{"C",2},{"H",3}<->{"C",2},{"C",1}<->{"C",2},{"O",1}<->{"C",1},{"H",4}<->{"O",1}},{{"H",1}<->{"C",1},{"C",2}<->{"C",1},{"H",2}<->{"C",2},{"C",2}<->{"C",1},{"O",1}<->{"C",2},{"H",3}<->{"O",1},{"H",4}<->{"C",1}},{{"H",1}<->{"C",1},{"H",2}<->{"C",1},{"C",2}<->{"C",1},{"H",3}<->{"C",2},{"C",2}<->{"C",1},{"O",1}<->{"C",2},{"H",4}<->{"O",1}},{{"H",1}<->{"C",1},{"H",2}<->{"C",1},{"C",2}<->{"C",1},{"C",2}<->{"C",1},{"O",1}<->{"C",2},{"H",3}<->{"O",1},{"H",4}<->{"C",2}},{{"H",1}<->{"C",1},{"H",2}<->{"C",1},{"H",3}<->{"C",1},{"C",2}<->{"C",1},{"O",1}<->{"C",2},{"C",2}<->{"O",1},{"H",4}<->{"C",2}}}
show=Graph[#, GraphLayout->"SpringEmbedding",
VertexStyle->{{"C",_}->Lighter[Black],{"O",_}->Lighter[Red],{"H",_}->LightBlue,{"N",_}-> Lighter[Blue]},
EdgeStyle-> Darker@Green,VertexSize->{{"C",_}->0.7,{"O",_}->0.5,{"H",_}->0.4,{"N",_}->0.6},
ImageSize->{210,200}]&;
Multicolumn@DeleteDuplicates[show/@del]
The last one is the same as blue ones (not the red one) in 2D. And IsomorphicGraphQ
would delete all but first one.
How can I delete these duplicates one?
Just consider planar isomerism, and I also glad to see if anyone solved the stereo isomerism.
Edit:
I don't know why you can't reproduce this.
I restarted my Kernels and got the same results.
$Version
show=Graph[#,GraphLayout->"SpringEmbedding",
VertexStyle->{{"C",_}->Lighter[Black],{"O",_}->Lighter[Red],{"H",_}->LightBlue,{"N",_}->Lighter[Blue]},
EdgeStyle->Darker@Green,VertexSize->{{"C",_}->0.7,{"O",_}->0.5,{"H",_}->0.4,{"N",_}->0.6},
ImageSize->{210,200}]&;
del={
{{"C",2}<->{"C",1},{"O",1}<->{"C",2},{"H",1}<->{"C",1},{"H",2}<->{"C",2},{"H",3}<->{"C",1},{"O",1}<->{"C",2},{"H",4}<->{"C",1}},
{{"C",2}<->{"C",1},{"H",1}<->{"C",2},{"O",1}<->{"C",1},{"H",2}<->{"C",2},{"C",1}<->{"O",1},{"H",3}<->{"C",2},{"H",4}<->{"C",1}},
{{"C",2}<->{"C",1},{"O",1}<->{"C",2},{"H",1}<->{"C",1},{"H",2}<->{"C",2},{"C",1}<->{"O",1},{"H",3}<->{"C",2},{"H",4}<->{"C",1}}
};
Quiet@DeleteDuplicatesBy[show/@del,CanonicalGraph]
DeleteDuplicatesBy[show/@del,IsomorphicGraphQ]
These are {1,2,5} of last del
.
If still have problems I may need to reinstall my Mathematica :).
del=DeleteDuplicates@raw
but in the end you useMulticolumn@DeleteDuplicates[show/@raw]
; what are we seeingraw
ordel
? 2.del[[{1, 2, 9, 12, 18, 20}]
does not match the presented output 3. there are rules about "N" which doesn't seem to be present - but that's not so important $\endgroup$DeleteDuplicates
operates on lists but yourdel
is not a simple list; perhaps you might be interested inDeleteDuplicatesBy
$\endgroup$del
... and I thinkMulticolumn
should be read by column (at least in my mathematica). I've tried again and usedDeleteDuplicatesBy
. $\endgroup$DeleteDuplicatesBy[graphs, CanonicalGraph]
or alternativelyDeleteDuplicates[graphs, IsomorphicGraphQ]
. Note the difference betweenDeleteDuplicates
andDeleteDuplicatesBy
. 2. Mathematica 11.2 has a very nasty bug where all isomorphism functionality is broken on Windows (Mac/Linux are fine). How this could have gotten through Wolfram's testing is beyond me. The good news is that my package IGraph/M can fully replace the built-in isomorphism stuff ... $\endgroup$