Package: cayleyR 0.2.5

cayleyR: Cayley Graph Analysis for Permutation Puzzles

Implements algorithms for analyzing Cayley graphs of permutation groups for the TopSpin puzzle. Provides methods for cycle detection, state space exploration and finding optimal operation sequences in permutation groups generated by shift and reverse operations. The method Iterative Cycle Intersection (ICI) is described in Yuri Baramykov (2026) <arxiv:2607.13219>.

Authors:Yuri Baramykov [aut, cre]

cayleyR_0.2.5.tar.gz
cayleyR_0.2.5.zip(r-4.7-x86_64)cayleyR_0.2.5.zip(r-4.6-x86_64)cayleyR_0.2.5.zip(r-4.5-x86_64)
cayleyR_0.2.5.tgz(r-4.6-x86_64)cayleyR_0.2.5.tgz(r-4.6-arm64)cayleyR_0.2.5.tgz(r-4.5-x86_64)cayleyR_0.2.5.tgz(r-4.5-arm64)
cayleyR_0.2.5.tar.gz(r-4.7-arm64)cayleyR_0.2.5.tar.gz(r-4.7-x86_64)cayleyR_0.2.5.tar.gz(r-4.6-arm64)cayleyR_0.2.5.tar.gz(r-4.6-x86_64)
cayleyR_0.2.5.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
cayleyR/json (API)

# Install 'cayleyR' in R:
install.packages('cayleyR', repos = c('https://zabis13.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/zabis13/cayleyr/issues

Uses libs:
  • c++– GNU Standard C++ Library v3
  • openmp– GCC OpenMP (GOMP) support library

On CRAN:

Conda:

cppopenmp

4.90 score 1 stars 203 downloads 75 exports 1 dependencies

Last updated from:39cf8a4b56. Checks:13 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK161
linux-devel-x86_64OK178
source / vignettesOK280
linux-release-arm64OK158
linux-release-x86_64OK179
macos-release-arm64OK180
macos-release-x86_64OK276
macos-oldrel-arm64OK112
macos-oldrel-x86_64OK268
windows-devel-x86_64OK167
windows-release-x86_64OK204
windows-oldrel-x86_64OK145
wasm-releaseOK129

Exports:analyze_top_combinationsapply_operationsapply_operations_batch_gpubidirectional_bfsbreakpoint_distancebuild_permutation_matrixcalculate_angular_distance_zcalculate_differencescalculate_midpoint_zcayley_bfs_fullcayley_distancecayley_distance_methodscayley_gpu_availablecayley_gpu_freecayley_gpu_initcayley_gpu_statuscayley_graph_diametercheck_duplicatescompose_permutation_matrixconvert_digitsconvert_LRX_to_celestialcreate_state_storecycle_shortcutfind_best_match_humanfind_best_random_combinationsfind_closest_to_coordsfind_combination_in_statesfind_path_bfsfind_path_iterativegenerate_stategenerate_unique_states_dfget_reachable_statesget_reachable_states_lighthuman_algorithmhuman_algorithm_tohuman_phase1_navigatehuman_phase1_rankinvert_pathmanhattan_distancemanhattan_distance_matrix_gpuopenmp_threadsreconstruct_bfs_pathreverse_prefixreverse_prefix_simplerun_lengthsave_bridge_statesselect_uniqueshift_leftshift_left_simpleshift_rightshift_right_simpleshort_path_bfsshort_positionsparse_bfsstate_store_indices_for_cyclestate_store_perm_lengthstate_store_sizestate_store_unique_countstore_add_from_dfstore_analyze_combosstore_analyze_combos_gpustore_clearstore_clear_opdstore_collect_opsstore_combos_for_statestore_filter_middlestore_find_best_matchstore_find_intersectionsstore_get_metastore_get_statestore_lookupstore_reconstruct_pathstore_set_opdstore_to_dataframevalidate_and_simplify_path

Dependencies:Rcpp

Function Reference
Basic Permutation Operations (C++) | shift_left(state, coords = NULL) | shift_right(state, coords = NULL) | reverse_prefix(state, k, coords = NULL) | shift_left_simple(state) | shift_right_simple(state) | reverse_prefix_simple(state, k) | apply_operations(state, operations, k, coords = NULL, compute_coords = TRUE) | openmp_threads() | Cycle Analysis | get_reachable_states(start_state, allowed_positions, k, verbose = FALSE) | get_reachable_states_light(start_state, allowed_positions, k) | analyze_top_combinations(top_combos, start_state, k) | Pathfinding | bidirectional_bfs(n, state1, state2, max_level, moves, k) | find_path_iterative(start_state, final_state, k, moves, combo_length, n_samples, n_top, max_iterations, potc, ptr, opd, reuse_combos, keep_states, one_sided, distance_method, sort_by, verbose) | find_path_bfs(start_state, final_state, k, ...) | sparse_bfs(start_state, k, n_hubs, n_random, max_levels) | reconstruct_bfs_path(bfs_result, target_key) | short_path_bfs(path, start_state, k, depth = 5) | cycle_shortcut(path, start_state, k, n_points = 20, moves, combo_length = 20, n_samples = 200, n_top = 5, sort_by, max_cycle_len = 20000, n_threads = NULL, verbose = FALSE) | human_algorithm(start_state, final_state = NULL, k = 4L, simplify = TRUE) | human_algorithm_cpp(start_state, k, max_ops, final_rotate) (internal) | human_algorithm_to(start_state, target_state = NULL, k = 4, simplify = TRUE) | human_phase1_rank(state, k = 4, sorted = TRUE) | human_phase1_navigate(state, k = 4, max_steps = 2000, trace = FALSE) | run_length(state) | find_best_match_human(states, target, k) | Combination Search | find_best_random_combinations(moves, combo_length, n_samples, n_top, start_state, k, sort_by) | Path Utilities | invert_path(path) | short_position(allowed_positions, n) | validate_and_simplify_path(path_candidate, start_state, final_state, k) | State Processing & Distance | calculate_differences(start_state, reachable_states_start, method, use_gpu) | select_unique(df) | check_duplicates(df1, df2) | manhattan_distance(start_state, target_state) | breakpoint_distance(start_state, target_state) | save_bridge_states(bridge_states, filename) | filter_middle_states(data, skip_first, skip_last) (internal) | find_best_match_state(target_state, reachable_states, method, use_gpu) (internal) | select_new_state(target_all, opposite_state, method) (internal) | cayley_distance_methods() | cayley_distance(method) | State Indexing | add_state_keys(states_df, new_states, v_cols) (internal) | create_hash_index(states_df) (internal) | State Store (C++ Backend) | create_state_store(perm_length, init_capacity) | state_store_size(xp) | state_store_unique_count(xp) | state_store_perm_length(xp) | store_add_from_df(store, df, cycle_val) | store_get_state(store, idx) | store_get_meta(store, idx) | store_find_intersections(store_a, store_b) | store_lookup(store, state) | store_find_best_match(store, target, candidate_indices) | store_filter_middle(store, target_cycle, skip_first, skip_last) | store_set_opd(store, target_cycle, combos) | store_clear_opd(store) | store_combos_for_state(store, state, target_cycle) | store_to_dataframe(store) | store_reconstruct_path(store, bridge_states, target_state, target_cycle, target_combo) | store_analyze_combos(store, top_combos, start_state, k, cycle_val) | store_analyze_combos_gpu(store, top_combos, start_state, k, cycle_val) | store_clear(store) | store_collect_ops(store, target_cycle, target_combo, end_step) | state_store_indices_for_cycle(xp, target_cycle) | Graph Metrics | cayley_bfs_full(start_state, k, moves = c("L", "R", "X")) | cayley_graph_diameter(start_state, k, moves, method = c("all_pairs", "from_start"), max_pairs = Inf, verbose = FALSE) | Celestial Coordinates | convert_LRX_to_celestial(nL, nR, nX) | calculate_angular_distance_z(result1, result2) | calculate_midpoint_z(coords1, coords2) | find_closest_to_coords(reachable_states, target_coords, v_cols) | GPU Acceleration (optional, requires ggmlR) | cayley_gpu_available() | cayley_gpu_init(device = 0, force = FALSE) | cayley_gpu_status() | cayley_gpu_free() | apply_operations_batch_gpu(states_matrix, operations, k) | manhattan_distance_matrix_gpu(states1, states2, batch_size = 256) | calculate_differences_gpu(start_state, states_matrix) (internal) | build_permutation_matrix(op, n, k) (internal) | compose_permutation_matrix(operations, n, k) (internal) | Utilities | convert_digits(s) | generate_state(n, k, n_moves, moves, max_attempts) | generate_unique_states_df(n, n_rows) | has_data_table() (internal) | Intersection Processing (internal) | reconstruct_full_path(reachable_states, start_state, target_state, target_cycle, target_combo, v_cols) | process_start_intersection(intersection_state, reachable_states_final, bridge_states_final, final_index, v_cols) | process_final_intersection(intersection_state, reachable_states_start, bridge_states_start, start_index, v_cols) | process_intermediate_intersection(intersection_state, reachable_states_start, reachable_states_final, bridge_states_start, bridge_states_final, start_index, final_index, v_cols) | State Search | find_combination_in_states(reachable_states_start, search_state)

Last update: 2026-07-24
Started: 2026-07-24

Solving Top Spin by Hand
Notation | Phase 1: build 1…12 | Why stop at 12 rather than 16 | Phase 2: sort the eight-tile tail (13…20) | Sequence A | Sequence B | Parity: why it sometimes refuses to finish | Finishing | Differences from the common description | Scope

Last update: 2026-07-24
Started: 2026-07-24

Readme and manuals

Help Manual

Help pageTopics
Analyze Top Operation Combinationsanalyze_top_combinations
Apply Sequence of Operationsapply_operations
Apply operations to batch of states on GPUapply_operations_batch_gpu
Bidirectional BFS Shortest Pathbidirectional_bfs
Breakpoint Distance Between Two Statesbreakpoint_distance
Build permutation matrix for a single operationbuild_permutation_matrix
Angular Distance Between Two Celestial Pointscalculate_angular_distance_z
Calculate Manhattan Distances for All Statescalculate_differences
Midpoint Between Two Celestial Coordinatescalculate_midpoint_z
Full Breadth-First Search Over the Cayley Graphcayley_bfs_full
Check if GPU acceleration is availablecayley_gpu_available
Free GPU backend resourcescayley_gpu_free
Initialize GPU backendcayley_gpu_init
Get GPU status informationcayley_gpu_status
Cayley Graph Diameter and Maximally Distant State Pairscayley_graph_diameter
Find Duplicate States Between Two Tablescheck_duplicates
Compose permutation matrices for a sequence of operationscompose_permutation_matrix
Convert String to Integer Vector of Digitsconvert_digits
Convert LRX Counts to Celestial Coordinatesconvert_LRX_to_celestial
Create a New State Storecreate_state_store
Shorten a Path by Cutting Across Cyclescycle_shortcut
Distance Methods for Bridge Selectioncayley_distance cayley_distance_methods distance_methods
Score Candidate States the Way a Person Solvesfind_best_match_human
Find Best Random Operation Sequencesfind_best_random_combinations
Find Closest State to Target Coordinatesfind_closest_to_coords
Find a State in Reachable States Tablefind_combination_in_states
Find Path via BFS Highwaysfind_path_bfs
Iterative Path Finder Between Permutation Statesfind_path_iterative
Generate Reachable Random Stategenerate_state
Generate Data Frame of Unique Random Statesgenerate_unique_states_df
Find Cycle in Permutation Groupget_reachable_states
Find Cycle Length (Lightweight Version)get_reachable_states_light
Solve a State with the Human TopSpin Algorithmhuman_algorithm
Human Algorithm Path Between Two Arbitrary Stateshuman_algorithm_to
Follow the Phase 1 Navigator to the Tailhuman_phase1_navigate
Rank Candidate Moves by the Phase 1 Criterionhuman_phase1_rank
Invert a Path of Operationsinvert_path
Manhattan Distance Between Two Statesmanhattan_distance
Compute Pairwise Manhattan Distance Matrix on GPUmanhattan_distance_matrix_gpu
Number of OpenMP Threads Availableopenmp_threads
Reconstruct path from sparse BFS resultreconstruct_bfs_path
Reverse First k Elements (with Coordinates)reverse_prefix
Reverse First k Elements (Simple)reverse_prefix_simple
Length of the Sorted Run on the Ringrun_length
Save Bridge States to CSVsave_bridge_states
Select Unique States by V-columnsselect_unique
Shift State Left (with Coordinates)shift_left
Shift State Left (Simple)shift_left_simple
Shift State Right (with Coordinates)shift_right
Shift State Right (Simple)shift_right_simple
Shorten Path via Depth-Limited BFS Hoppingshort_path_bfs
Simplify Operation Pathshort_position
Sparse BFS with Look-ahead and Hybrid Selectionsparse_bfs
Query a State Storestate_store_indices_for_cycle state_store_perm_length state_store_query state_store_size state_store_unique_count
Add States to Store from Data Framestore_add_from_df
Analyze Combinations Directly into Storestore_analyze_combos
Analyze Combinations into Store Using GPU Batch Operationsstore_analyze_combos_gpu
Drop All States From a Storestore_clear
Clear All OPD Filtersstore_clear_opd
Collect Operations Leading to a State Within One Cyclestore_collect_ops
Find Combo Numbers Containing a State in a Cyclestore_combos_for_state
Filter Middle States for a Cyclestore_filter_middle
Find Best Match by Manhattan Distancestore_find_best_match
Find Intersections Between Two Storesstore_find_intersections
Get Metadata for a Statestore_get_meta
Get State from Storestore_get_state
Lookup State Indices by State Vectorstore_lookup
Reconstruct Path from Storestore_reconstruct_path
Set OPD Combo Filter for a Cyclestore_set_opd
Convert Store to Data Framestore_to_dataframe
Validate and Simplify a Pathvalidate_and_simplify_path