Novel logarithmic time algorithm is proposed for determining the order of chemical bonds from known valences of the atoms. The algorithm has the order of complexity N · log(N) and is applicable to polycyclic compounds containing a combination of the cycles of any size and the atoms with the valences ≤4 in cycle nodes. The algorithm is applicable to structures containing triple and cumulene bonds in the cycles. It was tested for graphene, C[12,12] nanotubes, graphyne-GY1, graphyne-GY7, graphyne-like nanotube, fullerenes C20, C60, C70, C80, C82 and their aza-analogs, polypentadienes, as well as for porphine. Determining the order of bonds in graphene, graphynes or nanotubes, containing >107 atoms, took less than 2 min on a personal computer. For the compounds containing aromatic cycles with an odd number of atoms, this algorithm becomes probabilistic and successful determination of bond orders is not guaranteed. However, the probability of successful determination of bond order is significant, and Kekulé structures, if they existed, were generated for all studied fullerenes and their aza-analogs.