I have actually a molecule in cif format. I don't think that the format is really important, but provide it for those who are interested. This file has lots of data inside. What is most important (as this part of file actually describes molecule as a graph) is this part:
017 N1 C2 SING N N 1
017 N1 H11 SING N N 2
017 N1 H12 SING N N 3
017 C2 C3 DOUB Y N 4
017 C2 C7 SING Y N 5
017 C3 C4 SING Y N 6
This is not the whole file, it is just an example. This molecule may contain lots of cyclic structures. Aromatic ones I can define by Y flag in the 6 column. But there are also other cycles, which can be quiet different: or like that
or like that:
. Or even such ones:
What I need is to extract all the cycles in such a way, that if two cycles share the bond, like in the first example, they are considered as one cycle. Tarjan's algorithm won't work here because it runs each node once only. So how can I do that? Please provide as detailed information as possible. I am not really much interested in libraries, such as OpenBabel as I am going to write the thing in Swift and use graph description from cif file.