Skip to main content

Squashing Molecules Flat and Combinatorial Maps

So the traditional way to say it is probably 'planar embedding', but I've gone for the alternate terminology of 'squashing flat'. For many molecules, this is a fairly easy process : some decisions have to be made about rotatable bonds, but quite a few drugs are just things sticking off a benzene ring or two.

For fully 3-dimensional molecular graphs (for example) it is trickier. I don't yet know a simple algorithm for choosing different possible embeddings ... er ... squashings. Perhaps they are all complicated; they seem to involve tree data structures with names like "SPQR Tree" (see "Optimizing over all combinatorial embeddings of a planar graph").

Far easier, though, is the intermediate data structure between a graph and some 2D coordinates - known as a combinatorial map. These mathematical objects store the detail of the embedding by recording the order of 'half bonds' called flags (or darts?) around a vertex. Maybe a flag is the vertex and the half-bond. Anyway, here is a picture of K4 (or a squashed tetrahedrane skeleton):


Now the left hand side just shows the graph with labelled vertices, while the one on the right shows the flags (I'm going to call them that now, sorry). At the bottom is the permutation σ applied to the set of flags (f). To understand σ consider just the central vertex (1) : if we travel clockwise round from flag 1, we get the flags (1, 8, 6). In fact, this is how I constructed the permutation : clockwise round all the vertices. It can be helpful to consider σ in cycle notation as (0, 2, 4)(1, 6, 8)(5, 11, 9)(7, 10, 3) which has a cycle for each vertex.


This image shows two different embeddings of the same graph. Well, I suppose technically it is different embeddings of the same labelling. In any case, L and R are flipped : if there wasn't so much symmetry it might be better. The same procedure as before is used to get σL and σR (clockwise both times). Now check this out:


What is this crazy thing? Well, the other part of the combinatorial map is an 'involution' called α, which is really just another permutation that stores the pair of flags for each edge. In the images above, I have just ordered the edges using the vertices (as 0:1,0:2,0:3,1:2,1:3,2:3) then ordered the flags by vertex index : that is, α = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10].

Anyway, using the formula φ = σ ⋅ α we get a permutation of what I actually am going to call 'darts'. This is all on the wikipedia page, but it should be clear that the labelled arrows on the image go in cycles. So there is (0, 6, 3) for example. Indeed φ = (0, 6, 3)(1, 4, 9)(2, 10, 5)(7, 8, 11) which is - of course - the four faces of the embedding, including the boundary face.

Phew! Fun stuff, and there is code here as well as some tests here. Well more like just System.out statements, but the beginning of tests...

Comments

Popular posts from this blog

Adamantane, Diamantane, Twistane

After cubane, the thought occurred to look at other regular hydrocarbons. If only there was some sort of classification of chemicals that I could use look up similar structures. Oh wate, there is . Anyway, adamantane is not as regular as cubane, but it is highly symmetrical, looking like three cyclohexanes fused together. The vertices fall into two different types when colored by signature: The carbons with three carbon neighbours (degree-3, in the simple graph) have signature (a) and the degree-2 carbons have signature (b). Atoms of one type are only connected to atoms of another - the graph is bipartite . Adamantane connects together to form diamondoids (or, rather, this class have adamantane as a repeating subunit). One such is diamantane , which is no longer bipartite when colored by signature: It has three classes of vertex in the simple graph (a and b), as the set with degree-3 has been split in two. The tree for signature (c) is not shown. The graph is still bipartite accordin

Király's Method for Generating All Graphs from a Degree Sequence

After posting about the Hakimi-Havel  theorem, I received a nice email suggesting various relevant papers. One of these was by Zoltán Király  called " Recognizing Graphic Degree Sequences and Generating All Realizations ". I have now implemented a sketch of the main idea of the paper, which seems to work reasonably well, so I thought I would describe it. See the paper for details, of course. One focus of Király's method is to generate graphs efficiently , by which I mean that it has polynomial delay. In turn, an algorithm with 'polynomial delay' takes a polynomial amount of time between outputs (and to produce the first output). So - roughly - it doesn't take 1s to produce the first graph, 10s for the second, 2s for the third, 300s for the fourth, and so on. Central to the method is the tree that is traversed during the search for graphs that satisfy the input degree sequence. It's a little tricky to draw, but looks something like this: At the top

1,2-dichlorocyclopropane and a spiran

As I am reading a book called "Symmetry in Chemistry" (H. H. Jaffé and M. Orchin) I thought I would try out a couple of examples that they use. One is 1,2-dichlorocylopropane : which is, apparently, dissymmetric because it has a symmetry element (a C2 axis) but is optically active. Incidentally, wedges can look horrible in small structures - this is why: The box around the hydrogen is shaded in grey, to show the effect of overlap. A possible fix might be to shorten the wedge, but sadly this would require working out the bounds of the text when calculating the wedge, which has to be done at render time. Oh well. Another interesting example is this 'spiran', which I can't find on ChEBI or ChemSpider: Image again courtesy of JChempaint . I guess the problem marker (the red line) on the N suggests that it is not a real compound? In any case, some simple code to determine potential chiral centres (using signatures) finds 2 in the cyclopropane structure, and 4 in the