6

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]

enter image description here

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.

enter image description here

$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 :).

Aster
  • 3,836
  • 1
  • 18
  • 44
  • I cannot reproduce your result by your code – yode Jan 03 '18 at 06:34
  • at the start of the code snippet you use del=DeleteDuplicates@raw but in the end you use Multicolumn@DeleteDuplicates[show/@raw]; what are we seeing raw or del? 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
  • – user42582 Jan 03 '18 at 08:59
  • DeleteDuplicates operates on lists but your del is not a simple list; perhaps you might be interested in DeleteDuplicatesBy – user42582 Jan 03 '18 at 09:08
  • try DeleteDuplicatesBy[del, IsomorphicGraphQ] (there's nothing wrong with your installation as far as I can tell) – user42582 Jan 03 '18 at 09:46
  • 1
    @user42582 ,sry, that's del... and I think Multicolumn should be read by column (at least in my mathematica). I've tried again and used DeleteDuplicatesBy. – Aster Jan 03 '18 at 09:46
  • you are correct about MultiColumn; show /@ del[[{1, 5, 7, 12, 14, 20}]] produces the correct graphs; my bad – user42582 Jan 03 '18 at 09:56
  • Is filtering by coloured graph isomorphism acceptable for you? Or do you need to take the spatial structure into account? Filtering by coloured isomorphism should have been possible with IGraph/M, but there were some bugs that prevented it from working in this situation. I fixed those bugs and plan to release a new version soon. It looks like this: http://i.stack.imgur.com/4jsfU.png – Szabolcs Jan 03 '18 at 12:53
  • 1
    Some notes about your update to the question, which I didn't read before commenting. 1. That should be DeleteDuplicatesBy[graphs, CanonicalGraph] or alternatively DeleteDuplicates[graphs, IsomorphicGraphQ]. Note the difference between DeleteDuplicates and DeleteDuplicatesBy. 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 ... – Szabolcs Jan 03 '18 at 12:57
  • ... and works fine with M11.2 on Windows. Unfortunately, IGBlissCanonicalGraph had a serious bug, which I corrected today. Expect a new release by tomorrow. – Szabolcs Jan 03 '18 at 12:58
  • Possible duplicate: https://mathematica.stackexchange.com/q/22813/9490 – Jason B. Jan 03 '18 at 14:29
  • very closely related: https://mathematica.stackexchange.com/q/121050/9490 – Jason B. Jan 03 '18 at 23:16