The Floyd-Warshall Algorithm From Graph Principle, Utilized to Parsing Molecular Constructions | by LucianoSphere (Luciano Abriata, PhD) | Aug, 2024

Fingers-on explanations assisted by easy JavaScript code

The Floyd-Warshall algorithm is important in graph idea because it offers an environment friendly means to compute the shortest paths between all pairs of nodes in a graph. This traditional dynamic programming algorithm is extensively relevant past its conventional use in theoretical community evaluation. It really works by studying in a matrix that describes which pairs of nodes are linked by a single edge, and outputting the minimal variety of edges connecting each doable pair of nodes:

A set of nodes (pink) linked by edges (gentle inexperienced traces) after which 2 examples of the distances (numbers of hyperlinks between pairs of nodes, in darkish inexperienced with dashed traces) calculated by the Floyd-Warshall algorithm. The direct hyperlinks are encoded in a matrix known as the “adjency matrix” whose parts are 1 (nodes linked) or 0 (not linked). The output from the algorithm if a matrix of equal dimension however containing the distances between all nodes because the minimal numbers of edges separating any two of them. This and all different figures have been produced by the creator.

That is valuable details about connectivity inside the graph, that finds tons of functions; for instance in optimizing communication networks, analyzing contacts in social networks, or, as I’ll cowl right here, in parsing molecular constructions — on the core of many duties in cheminformatics and structural bioinformatics.

On this submit I’ll present you ways the Floyd-Warshall algorithm will be employed to compute bond distances between atoms in a molecule, or stated differently, the minimal variety of bonds separating each doable pair of atoms. Hopefully, my instance is not going to solely showcase the algorithm’s software in chemistry but in addition encourage you to make use of it for different functions in…