astar_lightest_path

compas.topology.astar_lightest_path(adjacency, weights, heuristic, root, goal)[source]

Find the path of least weight between two vertices of a graph using the A* search algorithm.

Parameters
  • adjacency (dict[hashable, dict[hashable, None]] | dict[hashable, sequence[hashable]]) – An adjacency dictionary representing the connectivity of the graph by mapping nodes identifiers to neighbour identifiers. Examples of valid adjacency dicts are

    • {0: [1, 2, 3, 4], 1: [0], 2: [0], 3: [0], 4: [0]}

    • {0: {1: None, 2: None, 3: None, 4: None}, 1: {0: None}, 2: {0: None}, 3: {0: None}, 4: {0: None}}

  • weights (dict[tuple[hashable, hashable], float]) – A dictionary of edge weights.

  • heuristic (dict[hashable, float]) – A dictionary of guesses of weights of paths from a node to the goal.

  • root (hashable) – The start vertex.

  • goal (hashable) – The end vertex.

Returns

list[hashable] | None – The path from root to goal, or None, if no path exists between the vertices.

References

https://en.wikipedia.org/wiki/A*_search_algorithm