Package: cayleyR 0.3.0

cayleyR: Cayley Graph Analysis for Permutation Puzzles

Analyzes Cayley graphs of permutation puzzles. Any puzzle whose moves permute a fixed set of positions can be declared as a permutation group, and the same tools then work on it: cycle detection, state space exploration and path search. Two puzzles are built in: TopSpin and Rubik's cubes of any size. The 3x3x3 is solved by four human methods and by a two-phase search after Herbert Kociemba; the 4x4x4 is solved by reduction. The Iterative Cycle Intersection (ICI) method is described in Yuri Baramykov (2026) <doi:10.48550/arXiv.2607.13219>.

Authors:Yuri Baramykov [aut, cre], Lucas Garron [ctb, cph], cubing.js authors [cph]

cayleyR_0.3.0.tar.gz
cayleyR_0.3.0.zip(r-4.7-x86_64)cayleyR_0.3.0.zip(r-4.7-arm64)cayleyR_0.3.0.zip(r-4.6-x86_64)cayleyR_0.3.0.zip(r-4.6-arm64)cayleyR_0.3.0.zip(r-4.5-x86_64)
cayleyR_0.3.0.tgz(r-4.6-x86_64)cayleyR_0.3.0.tgz(r-4.6-arm64)cayleyR_0.3.0.tgz(r-4.5-x86_64)cayleyR_0.3.0.tgz(r-4.5-arm64)
cayleyR_0.3.0.tar.gz(r-4.7-arm64)cayleyR_0.3.0.tar.gz(r-4.7-x86_64)cayleyR_0.3.0.tar.gz(r-4.6-arm64)cayleyR_0.3.0.tar.gz(r-4.6-x86_64)
cayleyR_0.3.0.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:

cayley-graphpermutationspuzzle-solvercppopenmp

5.69 score 1 stars 389 downloads 172 exports 1 dependencies

Last updated from:8da1c75d2d. Checks:15 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK189
linux-devel-x86_64OK215
source / vignettesOK308
linux-release-arm64OK176
linux-release-x86_64OK211
macos-release-arm64OK173
macos-release-x86_64OK429
macos-oldrel-arm64OK197
macos-oldrel-x86_64OK529
windows-devel-arm64OK390
windows-devel-x86_64OK300
windows-release-arm64OK330
windows-release-x86_64OK264
windows-oldrel-x86_64OK197
wasm-releaseOK132

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_celestialconvex_hull_3dcreate_state_storecube_adi_astarcube_adi_loadcube_adi_modelcube_adi_savecube_adi_solvecube_adi_traincube_alg_tablecube_apply_wordcube_at_phase_goal_cppcube_build_lslicecube_central_movescube_centre_countscube_centre_cyclescube_centre_positionscube_centre_shotscube_centre_structurecube_colour_statecube_colourscube_edge_algscube_edge_countscube_edge_mapcube_edge_structurecube_empty_u_slicecube_expand_algcube_expand_movecube_expand_wordcube_free_movescube_groupcube_identitycube_is_colour_solvedcube_is_reducedcube_kociembacube_kociemba_initcube_kociemba_reportcube_kociemba4cube_kociemba4_fill_phase3_cppcube_kociemba4_phase12_cppcube_kociemba4_phase3_cppcube_kociemba4_reducecube_kociemba4_reportcube_kociemba4_tables_cppcube_layer_movecube_lslice_cellscube_move_namescube_movescube_moves_santacube_orbitscube_pair_edgescube_phase3_coord_cppcube_piece_layoutcube_piecescube_pieces_homecube_predicatescube_progresscube_read_statecube_reduce_bestcube_reduce_cppcube_santa_groupcube_santa_move_namescube_santa_movescube_santa_pathcube_santa_path_outcube_santa_permcube_santa_statecube_santa_state_outcube_slice_cells_cppcube_slice_mapcube_solve_centrescube_solve_cfopcube_solve_lblcube_solve_m2cube_solve_old_pochmanncube_solve4cube_solve4_cascadecube_to_pieces4_cppcube_wide_movecube_wide_turncube_wide_wordcube_wing_geometry_cppcube_word_ordercycle_shortcutenclosing_hull_3dfind_best_match_cube4_modelfind_best_match_humanfind_best_random_combinationsfind_closest_to_coordsfind_combination_in_statesfind_path_bfsfind_path_iterativegenerate_stategenerate_unique_states_dfgenerate_walkget_reachable_statesget_reachable_states_lightgroup_applygroup_composegroup_identitygroup_inverse_seqgroup_move_indexgroup_movesgroup_ordergroup_parse_wordhuman_algorithmhuman_algorithm_tohuman_phase1_navigatehuman_phase1_rankinvert_pathis_perm_grouplandmark_statesmanhattan_distancemanhattan_distance_matrix_gpuopenmp_threadsperm_groupreconstruct_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_groupstore_lookupstore_reconstruct_pathstore_set_opdstore_to_dataframetopspin_groupvalidate_and_simplify_path

Dependencies:Rcpp

Neural Solvers
Training data: generate_walk() | Learning without labels: autodidactic iteration | Build the networks | Train | Save, load, train further | Solving | Measuring a solver | Q-models: the example scripts

Last update: 2026-10-16
Started: 2026-10-16

Permutation Groups
Two built-in puzzles | Applying moves | Order of a word | A puzzle of your own | Random states | Subgroups | Old calls still work

Last update: 2026-10-16
Started: 2026-10-16

The 4x4x4 Cube
Moves | Reduction | cube_solve4(): always finishes | cube_kociemba4(): short, but not always | cube_solve4_cascade(): the best of both | Santa 2023 notation

Last update: 2026-10-16
Started: 2026-10-16

The Rubik's Cube
Stickers and moves | Colours | A scramble | Five solvers | Stages | Kociemba | Other sizes

Last update: 2026-10-16
Started: 2026-10-16

Landmark States and the Solid They Span
1. Landmark states | Rotations are free | 2. Distances | Why not human_algorithm() | 3. Picking six pairs | 4. Where a landmark sits | 5. The solid | Results | What this does and does not establish | Running it

Last update: 2026-07-27
Started: 2026-07-27

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
Convex Hull of a 3-D Point Cloudconvex_hull_3d
Create a New State Storecreate_state_store
Autodidactic Iteration on a Permutation Puzzlecube_adi
Batch Weighted A* With a Learned Heuristiccube_adi_astar
Load a Trained ADI Networkcube_adi_load
Build the Value and Policy Networkscube_adi_model
Save a Trained ADI Networkcube_adi_save
Solve a Cube With a Trained Networkcube_adi_solve
Train Value and Policy by Autodidactic Iterationcube_adi_train
The Algorithm Tablescube_alg_table
Apply a Word of Moves to a Cube Statecube_apply_word
Build the Layer Beside a Face, at Any Sizecube_build_lslice
Slice Turns That Reorient the Whole Cubecube_central_moves
Count the Centre Pieces That Are Homecube_centre_counts
Three-Cycles of Centres, One Per Orbitcube_centre_cycles
The Centres of a Cube of Any Size, Derivedcube_centre_map_family
Sticker Positions of the Six Centrescube_centre_positions
Commutators That Carry Centres Off One Face and Spare Anothercube_centre_shots
Centre Stickers of an N x N x N Cubecube_centre_structure
Colours and Positions: the Two Ways to Write a Cube Downcube_colours cube_colour_state
The Published Edge-Pairing Algorithms, at Any Sizecube_edge_algs
How Many Edges Are Wholecube_edge_counts
Where a Turn Sends Each Edge Piececube_edge_map
The Edges of a Cube of Any Size, Derivedcube_edge_map_family
Edge Pieces of an N x N x N Cubecube_edge_structure
Empty the Top Face onto the Sidescube_empty_u_slice
Expand an Algorithm into the Package's Alphabetcube_expand_alg
Wide Turns and Whole-Cube Rotationscube_expand_move cube_expand_word cube_wide_move cube_wide_word
The Group of an N x N x N Cubecube_group
Solved State of an N x N x N Cubecube_identity
Test Whether Every Face of a Cube is a Single Colourcube_is_colour_solved
Is a Cube Reduced?cube_is_reduced
Solve a 3x3x3 by Two-Phase Searchcube_kociemba
Build the Kociemba Prune Tablescube_kociemba_init
What the Last Kociemba Solve Didcube_kociemba_report
Solve a 4x4x4 by Four-Phase Searchcube_kociemba4
Reduce a 4x4x4 by Four-Phase Searchcube_kociemba4_reduce
What the Last 4x4x4 Reduction Didcube_kociemba4_report
A Single Layer Turn, by Axis and Layercube_layer_move
The Layer Beside a Face, and What Leaves It Alonecube_free_moves cube_lslice_cells
Move Names of an N x N x N Cubecube_move_names
Move Table of an N x N x N Cubecube_moves
Cubes of Any Sizecube_nnn
Orbits of an N x N x N Cubecube_orbits
Piece Orbits of a Cube of Any Sizecube_orbits_family
Pair the Edges of a Cube of Any Sizecube_pair_edges
The Piece Layout a Cube State Is Read Throughcube_piece_layout
Pieces of an N x N x N Cubecube_pieces
Pieces Home on a Cubecube_pieces_home
Stage Predicates of a Cube Statecube_predicates
How Much of Each Orbit Is Solvedcube_progress
Read a Cube State as Piecescube_read_state
Reduce a 4x4x4, Trying Every Starting Facecube_reduce_best
Reduce a 4x4x4 by the human methodcube_reduce_cpp
The Santa 2023 Cube Notationcube_santa
A Cube Group in Santa 2023 Notationcube_santa_group
Santa 2023 Move Names for a Cubecube_santa_move_names
Translate Between Santa 2023 and Package Move Namescube_moves_santa cube_santa_moves
Translate a Santa 2023 Solution Pathcube_santa_path cube_santa_path_out
Sticker Relabelling Between Santa 2023 and This Packagecube_santa_perm
Read and Write Santa 2023 Cube Statescube_santa_state cube_santa_state_out
The Layer Beside a Face, as the 4x4x4 Solver Sees Itcube_slice_cells_cpp
Where a Slice Turn Sends Each Centrecube_slice_map
Solve the Centres of a 4x4x4 Cubecube_solve_centres
Solve a 3x3x3 Cube by CFOPcube_solve_cfop
Solve a 3x3x3 Cube Layer by Layercube_solve_lbl
Solve a 3x3x3 Cube by M2cube_solve_m2
Solve a 3x3x3 Cube by Old Pochmanncube_solve_old_pochmann
Solve a 4x4x4 Cube by Reductioncube_solve4
Solve a 4x4x4 by reduction, falling back when the search does not pay offcube_solve4_cascade
Wide Turns of an N x N x N Cubecube_wide_turn
Order of a Word of Movescube_word_order
Shorten a Path by Cutting Across Cyclescycle_shortcut
Distance Methods for Bridge Selectioncayley_distance cayley_distance_methods distance_methods
Enclosing Hull Through Every Pointenclosing_hull_3d
Score Candidate States With a Trained 4x4x4 Modelfind_best_match_cube4_model
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
Random Walks From the Solved State, With the Moves They Tookgenerate_walk
Find Cycle in Permutation Groupget_reachable_states
Find Cycle Length (Lightweight Version)get_reachable_states_light
Apply a Move Sequence Through a Groupgroup_apply
Compose a Move Sequence into One Permutationgroup_compose
Solved State of a Groupgroup_identity
Invert a Move Sequencegroup_inverse_seq
Resolve Move Names to Indices Within a Groupgroup_move_index
Move Alphabet of a Groupgroup_moves
Order of a Move Sequence in a Groupgroup_order
Parse a Word Written as One Stringgroup_parse_word
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
Test Whether an Object is a Permutation Groupis_perm_group
The 4x4x4 reduction phases, one call at a timecube_at_phase_goal_cpp cube_kociemba4_fill_phase3_cpp cube_kociemba4_phase12_cpp cube_kociemba4_phase3_cpp cube_kociemba4_tables_cpp cube_phase3_coord_cpp cube_to_pieces4_cpp cube_wing_geometry_cpp kociemba4_phases
Generate Landmark States for a Permutation of Size nlandmark_states
Manhattan Distance Between Two Statesmanhattan_distance
Compute Pairwise Manhattan Distance Matrix on GPUmanhattan_distance_matrix_gpu
Number of OpenMP Threads Availableopenmp_threads
Create a Permutation Group from a Table of Movesperm_group
Permutation Groupsperm_group_intro
Print a Permutation Groupprint.perm_group
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
Group Attached to a State Storestore_group
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
Create the TopSpin Grouptopspin_group
Validate and Simplify a Pathvalidate_and_simplify_path