0

I would like to implement the following in Python but not sure where to start. Are there good modules for shortest path problems of this type?

I am trying to define the shortest path from a particular atom (node) to all other atoms (nodes) in a given collection of xyz coordinates for a 3D chemical structure (the graph). The bonds between the atoms (nodes) are the edges for which travel from node to node is allowed.

I am trying to filter out certain atoms (nodes) from the molecule (graph) based on the connectivity outward from a selected central node.

**For the paths considered, I want to FORBID certain atoms (nodes) from being crossed. If the shortest path from A to B is through forbidden node, this answer is disallowed. The shortest path from A to B must not include the forbidden node **

If the shortest path from the selected centre atom (A) to another other node(B) INCLUDES the forbidden node, AND there is no other path available from A to B through the available edges (bonds), then node B should be deleted from the final set of xyz coordinates (nodes) to be saved.

This should be repeated for A to C, A to D, A to E, etc. for all other atoms (nodes) in the structure (graph).

Thanks in advance for any help you can offer.

2 Answers2

0

Make sure all edges that would lead to the forbidden node(s) have an infinite cost, and whichever graph-traversing algorithm you use will deal with it automatically.

Alternatively, just remove the forbidden nodes from being considered by the graph traversal algorithm.

AKX
  • 152,115
  • 15
  • 115
  • 172
0

To answer the first part of your question, I recommend networkx. It's a general purpose graphing library that's pretty easy to get into (I used it in my PhD).

Kyle_S-C
  • 1,107
  • 1
  • 14
  • 31