Cython Spaces

Warning

Add text describing the inheritance structure, and the need to hold a union.

class Euclidean2D(*args, **kwargs)

\(\mathbb{R}^2\) with \(L_2\)-induced metric (Euclidean).

Parameters:

velocity – constant velocity to compute travel time, optional. default: 1

__reduce__(self)
asdict(self)
random_point(self)
class Manhattan2D(*args, **kwargs)

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

Parameters:

velocity – constant velocity to compute travel time, optional. default: 1

__reduce__(self)
asdict(self)
random_point(self)
class Graph(vertices, edges, weights=None, double velocity=1)

Weighted directed graph with integer node labels.

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

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

  • weights (Union[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 – constant velocity to compute travel time, optional. default: 1

__reduce__(self)
asdict(self)
classmethod from_nx(cls, G, double velocity: float = 1.0, unicode make_attribute_distance: Optional[str] = u'distance')

Create a Graph from a networkx.Graph with a mandatory distance edge attribute.

Parameters:
  • G (networkx.Graph) – networkx graph

  • velocity (float) – velocity used for travel time computation

  • make_attribute_distance (str | None) – name of the nx.DiGraph edge attribute used as distance between nodes. If None is supplied, the resulting graph is unweighted (unit edge length).

Returns:

Graph instance

random_point(self)
class TransportSpace(loc_type)

Base class for extension types wrapping C++ TransportSpace class template. Since there’s no elegant way of wrapping templates in cython and exposing them to python, we will use the [Explicit Run-Time Dispatch approach] (https://martinralbrecht.wordpress.com/2017/07/23/adventures-in-cython-templating/). See the docstring of ridepy/data_structures_cython/data_structures.pyx for details.

asdict(self)
interp_dist(self, u, v, double dist_to_dest)
interp_time(self, u, v, double time_to_dest)

Warning

Add text describing how the graphs can only hold integers as nodes and how we automatically relabel the nodes.