Learn R Programming

cayleyR (version 0.2.1)

calculate_differences: Calculate Manhattan Distances for All States

Description

Computes the Manhattan distance from a reference state to every row in a table of reachable states, adds a difference column, and sorts by it.

Usage

calculate_differences(
  start_state,
  reachable_states_start,
  method = "manhattan",
  use_gpu = FALSE
)

Value

Data frame sorted by difference (ascending)

Arguments

start_state

Integer vector, the reference state

reachable_states_start

Data frame with V-columns

method

Character, distance method (currently only "manhattan")

use_gpu

Logical, use GPU acceleration via ggmlR if available (default FALSE)

Examples

Run this code
df <- data.frame(V1 = c(1, 2), V2 = c(2, 1))
calculate_differences(c(1, 2), df)

Run the code above in your browser using DataLab