cayleypy.find_path
- cayleypy.find_path(graph: CayleyGraph, start_state: Tensor | ndarray | list, **kwargs) list[int] | None [source]
Finds path from
start_state
to central state.This function will try to automatically pick the best algorithm. It will return
None
if path was not found, which can happen if path does not exist, or if it exists but the algorithm failed to find it.The path is returned as list of generator numbers. Use
graph.definition.path_to_string(path)
to convert it to string.If you want to compute paths from multiple different states for the same graph, use the same instance of
graph
and pass it here. This will allow doing some computations only once (on the first call) and caching the results, making subsequent path computations faster.In practice, this will work only for very small graphs, very short paths, and for graphs for which the library has pre-computed ML models. Also, there is no guarantee that the path fill be the shortest (although this function will try to find short path). Therefore, it’s recommended to use specialized algorithms for path finding instead of this function.
- Parameters:
graph – Graph in which to find the path.
start_state – First state of the path.
- Returns:
The found path (list of generator ids), or
None
if path was not found.