Learn R Programming

cayleyR (version 0.1.0)

get_reachable_states: Find Cycle in Permutation Group

Description

Explores the Cayley graph starting from an initial state and applying a sequence of operations repeatedly until returning to the start state. Returns detailed information about all visited states and the cycle structure.

Usage

get_reachable_states(start_state, allowed_positions, k, verbose = FALSE)

Value

List containing:

states

List of all visited states

reachable_states_df

Data frame with states, operations, and step numbers

operations

Vector of operations applied

total_moves

Total number of moves in the cycle

unique_states_count

Number of unique states visited

cycle_info

Summary string with cycle statistics

Arguments

start_state

Integer vector, the initial permutation state

allowed_positions

Character vector, sequence of operations to repeat

k

Integer, parameter for reverse operations

verbose

Logical; if TRUE, prints progress and cycle information messages (default FALSE)

Examples

Run this code
# Simple example with letter codes
result <- get_reachable_states(1:20, c("L", "X"), k = 4)
writeLines(result$cycle_info)

# Example with numeric codes
n <- 20
k <- 4
start_state <- 1:n
allowed_positions <- c("1", "3", "2")
result <- get_reachable_states(start_state, allowed_positions, k)
writeLines(result$cycle_info)
head(result$reachable_states_df)

Run the code above in your browser using DataLab