Skip to contents

Among trajectories closest to a target vertex, selects the one with the most vertices. This is useful when multiple trajectories are equally close to a landmark and a tiebreaker is needed.

Usage

select.closest.longest.trajectory(
  trajectories,
  traj.dists,
  distance.tolerance = 1e-09
)

Arguments

trajectories

A list of integer vectors, each representing a trajectory.

traj.dists

Output from trajectory.distances.to.vertex.

distance.tolerance

Numeric tolerance for considering distances equal. Trajectories within this tolerance of the minimum distance are considered tied. Default is 1e-9.

Value

A list with components:

best.idx

Index of the selected trajectory in the input list.

trajectory

The selected trajectory (integer vector of vertices).

min.distance

Distance from the selected trajectory to the target.

n.vertices

Number of vertices in the selected trajectory.

n.tied

Number of trajectories tied at the minimum distance.

tied.idx

Indices of all tied trajectories.