mooonpy.molspace.graph_theory.interface module
This module provides basic support for generating and working with graphs. The main purpose is to provide an interface between a Molspace instance and the graph data structure used in all the graph theory supported workflows.
- mooonpy.molspace.graph_theory.interface.find_cumulative_neighs(graph: dict[int, list[int]], node: int, max_depth: int)[source]
Finds the cummulative neighbors of a graph starting at a given node and traversing to a maximum depth of max_depth. Depth is defined as follows:
first neighbors
second neighbors
thrid neighbors
Note
For rings/cycles, where each neighbor has two classifications of depth due to ring symmetry, the lowest neighbor depth classification will be assigned and it will not be duplicated in the higher neighbor depth set.
- Parameters:
graph (dict[int, list[int]]) – An undirected graph
node (int) – A node to find all cummulative neighbors from
max_depth (int) – The maximum traversal depth to search (typically 4)
- Returns:
neighbors
- Return type:
dict[int, set[int]]
- mooonpy.molspace.graph_theory.interface.generate_graph(mol: Molspace)[source]
Generates an undirected graph from a Molspace instance.
Note
The generated graph will contain the most current nodes/edges each time this function is called. Thus if adding atoms/bonds to a Molspace instance, it is important to first update the Molspace instance before calling this function.
- Parameters:
mol (Molspace) – Molspace instance to generate undirected graph from
- Returns:
graph
- Return type:
dict[int, list[int]]