The spaces

class Euclidean(n_dim=1, coord_range=None, velocity=1)[source]

n-dimensional Euclidean space with constant velocity.

Initialize n-dimensional Euclidean space with constant velocity.

Parameters:
  • n_dim (int) – number of dimensions

  • coord_range (List[Tuple[int | float, int | float]]) – coordinate range of the space as a list of 2-tuples (x_i,min, x_i,max) where x_i represents the ith dimension.

  • velocity (float) – constant scaling factor as discriminator between distance and travel time

class Manhattan2D(coord_range=None, velocity=1)[source]

\(\mathbb{R}^2\) with \(L_1\)-induced metric (Manhattan).

Parameters:
  • coord_range (List[Tuple[int | float, int | float]]) – coordinate range of the space as a list of 2-tuples (x_i,min, x_i,max) where x_i represents the ith dimension.

  • velocity (float) – constant scaling factor as discriminator between distance and travel time

class Graph(vertices, edges, weights=None, velocity=1)[source]

A location is identified with a one-dimensional coordinate, namely the node index.

Weighted undirected graph with integer vertex labels

Parameters:
  • vertices (Sequence[int]) – sequence of vertices

  • edges (Sequence[Tuple[int, int]]) – sequence of edge tuples

  • weights (None | float | Sequence[float]) – Edge weights. - if None is supplied, the resulting graph is unweighted (unit edge length) - if a single float is supplied, every edge length will be equal to this number - if a sequence is supplied, this will be mapped onto the edge sequence

  • velocity (float) – constant velocity to compute travel time, optional.

static _make_attribute_distance(G, attribute_name)[source]

Set the distance attribute on the edges of the graph inplace.

Parameters:
  • G – The graph to modify

  • attribute_name (str | None) – The name of the attribute to use as distance. If None, the distance will be set to 1 for each edge.

classmethod from_nx(G, velocity=1, make_attribute_distance='distance')[source]

Create a graph space from NetworkX graph.

Parameters:
  • G (Graph) – the networkx.Graph instance, will be deepcopied

  • velocity (float) – velocity to use for travel time computation

  • make_attribute_distance (str) – attribute to rename to “distance” and use as such If None is supplied, the resulting graph is unweighted (unit edge length).

Returns:

graph space instance

interp_dist(u, v, dist_to_dest)[source]
Parameters:
  • u

  • v

  • dist_to_dest

Returns:

  • next_node

  • jump_distance

interp_time(u, v, time_to_dest)[source]
Parameters:
  • u

  • v

  • time_to_dest

Returns:

  • next_node

  • jump_time