Skip to contents

For each trajectory in a list, computes the minimum graph distance from any vertex in the trajectory to a specified target vertex. This is useful for identifying trajectories that pass near a landmark vertex (e.g., a community state type centroid) without necessarily including it.

Usage

trajectory.distances.to.vertex(
  trajectories,
  target.vertex,
  adj.list,
  weight.list
)

Arguments

trajectories

A list of integer vectors, where each vector contains vertex indices forming a trajectory. Vertex indices should be 1-based.

target.vertex

Integer specifying the target vertex index (1-based).

adj.list

List of integer vectors specifying the adjacency structure. Each element adj.list[[i]] contains the indices of vertices adjacent to vertex i.

weight.list

List of numeric vectors specifying edge weights (lengths). Each element weight.list[[i]] contains the weights of edges from vertex i to its neighbors in adj.list[[i]].

Value

A list with components:

min.distances

Numeric vector of length equal to the number of trajectories. Each element is the minimum graph distance from any vertex in the corresponding trajectory to the target vertex.

nearest.vertices

Integer vector of the trajectory vertex that achieves the minimum distance to the target for each trajectory.

nearest.positions

Integer vector of the position within each trajectory where the nearest vertex occurs (1-based).

target.vertex

The target vertex index (for reference).

Details

The function constructs an igraph object from the adjacency and weight lists, then computes shortest path distances from the target vertex to all vertices in the graph. For each trajectory, it identifies the vertex with the smallest distance to the target and records both the distance and the vertex identity.

Trajectories that pass through the target vertex will have a minimum distance of zero.

See also

vertex.all.trajectories.gfc.flow for extracting trajectories from a GFC flow result, cell.trajectories for extracting trajectories within a specific cell

Examples

if (FALSE) { # \dontrun{
## Get all trajectories descending to minimum m2
m2.trajs <- vertex.all.trajectories.gfc.flow(gfc.res, m2.vertex)

## Find which trajectories pass closest to the Li landmark
traj.dists <- trajectory.distances.to.vertex(
    trajectories = m2.trajs,
    target.vertex = Li.vertex,
    adj.list = adj.list,
    weight.list = weight.list
)

## Select trajectories within distance 0.5 of Li
near.Li.idx <- which(traj.dists$min.distances < 0.5)
} # }