mesa_frames.Grid.get_distances#

Grid.get_distances(pos0: int | Sequence[int] | DataFrame | Sequence[int | slice | Sequence[int]] | Collection[int | Sequence[int] | DataFrame] | None = None, pos1: int | Sequence[int] | DataFrame | Sequence[int | slice | Sequence[int]] | Collection[int | Sequence[int] | DataFrame] | None = None, agents0: int | Collection[int] | Series | DataFrame | AbstractAgentSet | AbstractAgentSetRegistry | Collection[AbstractAgentSet] | Collection[AbstractAgentSetRegistry] | None = None, agents1: int | Collection[int] | Series | DataFrame | AbstractAgentSet | AbstractAgentSetRegistry | Collection[AbstractAgentSet] | Collection[AbstractAgentSetRegistry] | None = None) DataFrame#

Return the distances from pos0 to pos1 or agents0 and agents1.

If the space is a Network, the distance is the number of nodes of the shortest path between the two nodes. In all other cases, the distance is Euclidean/l2/Frobenius norm. You should specify either positions (pos0, pos1) or agents (agents0, agents1), not both and they must have the same length.

Parameters:
  • pos0 (SpaceCoordinate | SpaceCoordinates | None, optional) – The starting positions

  • pos1 (SpaceCoordinate | SpaceCoordinates | None, optional) – The ending positions

  • agents0 (IdsLike | AbstractAgentSet | AbstractAgentSetRegistry | Collection[AbstractAgentSet] | Collection[AbstractAgentSetRegistry] | None, optional) – The starting agents

  • agents1 (IdsLike | AbstractAgentSet | AbstractAgentSetRegistry | Collection[AbstractAgentSet] | Collection[AbstractAgentSetRegistry] | None, optional) – The ending agents

Returns:

A DataFrame where each row represents the distance from pos0 to pos1 or agents0 to agents1

Return type:

DataFrame