| Title: | Interactive 3D Visualization of Large Cayley Graphs via Vulkan |
|---|---|
| Description: | Provides interactive 3D visualization for large-scale Cayley graphs. Specifically designed for analyzing state spaces of the 'TopSpin' puzzle. Leverages the 'Datoviz' library and Vulkan-based GPU rendering for smooth real-time exploration of large graphs and complex state transitions. Implements efficient coordinate mapping for high-dimensional permutation groups, allowing users to visualize the connectivity and structural properties of the puzzle's state space. The rendering engine provides high-performance visuals and interactive camera controls, making it suitable for mathematical analysis of group-theoretic puzzles within the R environment. |
| Authors: | Yuri Baramykov [aut, cre] (ORCID: <https://orcid.org/0009-0000-7627-4217>), Cyrille Rossant [ctb, cph] (Author of the Datoviz library) |
| Maintainer: | Yuri Baramykov <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.2 |
| Built: | 2026-05-11 22:18:20 UTC |
| Source: | https://github.com/cran/cgvR |
Set the panel background to a solid color or a 4-corner gradient.
cgv_background(viewer, color)cgv_background(viewer, color)
viewer |
External pointer returned by |
color |
A single color string (e.g. |
No return value, called for side effects: updates the panel's
background color on the GPU. Returns NULL invisibly.
Set Camera Position and Direction
cgv_camera(viewer, position = c(0, 0, 5), target = c(0, 0, 0), up = c(0, 1, 0))cgv_camera(viewer, position = c(0, 0, 5), target = c(0, 0, 0), up = c(0, 1, 0))
viewer |
External pointer returned by |
position |
Numeric vector of length 3 (x, y, z). |
target |
Numeric vector of length 3 — look-at point. |
up |
Numeric vector of length 3 — up direction. |
No return value, called for side effects: updates the camera's
position, look-at target and up vector on the active panel. Returns
NULL invisibly.
Switch Camera Mode
cgv_camera_mode(viewer, mode = c("fly", "orbit"))cgv_camera_mode(viewer, mode = c("fly", "orbit"))
viewer |
External pointer returned by |
mode |
Character: |
No return value, called for side effects: switches the active
camera between fly and orbit interaction modes. Returns NULL
invisibly.
Remove path highlight and restore original node colors and sizes.
cgv_clear_path(viewer)cgv_clear_path(viewer)
viewer |
External pointer returned by |
No return value, called for side effects: removes the path
highlight overlay and restores original node colors and sizes.
Returns NULL invisibly.
Close the Viewer
cgv_close(viewer)cgv_close(viewer)
viewer |
External pointer returned by |
No return value, called for side effects: releases the
underlying Vulkan application, GPU resources and (in windowed mode)
the GLFW window held by viewer. Returns NULL invisibly.
Smoothly animate the camera along a sequence of 3D waypoints using Catmull-Rom spline interpolation.
cgv_fly_path(viewer, positions, duration = 5, loop = FALSE)cgv_fly_path(viewer, positions, duration = 5, loop = FALSE)
viewer |
External pointer returned by |
positions |
Numeric matrix with 3 columns (x, y, z), one row per waypoint. |
duration |
Total animation duration in seconds. |
loop |
Logical: loop the animation? |
No return value, called for side effects: starts a Catmull-Rom
spline camera animation through the given waypoints. Returns
NULL invisibly.
Smoothly animate the camera to center on a given node.
Requires that cgv_set_graph was called first (for node positions).
cgv_fly_to(viewer, node_id, duration = 1)cgv_fly_to(viewer, node_id, duration = 1)
viewer |
External pointer returned by |
node_id |
Integer node identifier (1-based R index). |
duration |
Animation duration in seconds. |
No return value, called for side effects: starts a camera
animation toward the chosen node. Returns NULL invisibly.
Draw a highlighted path between nodes. Path nodes get a distinct color and enlarged size; path edges are drawn as thick colored segments on top of existing edges.
cgv_highlight_path( viewer, path, color = "#FF0000", node_scale = 2, edge_width = 5 )cgv_highlight_path( viewer, path, color = "#FF0000", node_scale = 2, edge_width = 5 )
viewer |
External pointer returned by |
path |
Integer vector of node IDs forming the path (1-based). |
color |
Color as hex string |
node_scale |
Numeric: size multiplier for highlighted nodes (default 2.0). |
edge_width |
Numeric: line width for path edges (default 5.0). |
No return value, called for side effects: adds (or replaces)
the highlight overlay for the given path. Returns NULL
invisibly.
Returns TRUE when cgvR was installed without native rendering
support (no Vulkan / GLFW found at install time). In that case all
rendering functions raise an error; pure-R helpers like
cgv_layout_fr still work.
cgv_is_stub_build()cgv_is_stub_build()
Logical scalar.
Computes 3D (or 2D) node positions so that connected nodes settle at
approximately equal distance ideal_len, while non-adjacent nodes
repel each other. Implements the Fruchterman-Reingold algorithm with
linearly-cooling temperature, fully vectorized over nodes and edges.
cgv_layout_fr( n_nodes, edges, n_iter = 300L, ideal_len = NULL, dim = 3L, seed = NULL, init = NULL, cool = 0.98, normalize = TRUE, verbose = FALSE )cgv_layout_fr( n_nodes, edges, n_iter = 300L, ideal_len = NULL, dim = 3L, seed = NULL, init = NULL, cool = 0.98, normalize = TRUE, verbose = FALSE )
n_nodes |
Integer. Number of nodes. |
edges |
Two-column integer matrix |
n_iter |
Integer. Number of iterations (default 300). |
ideal_len |
Numeric. Target edge length. If |
dim |
Integer, 2 or 3. Output dimensionality (default 3). |
seed |
Optional integer for reproducible initialization. |
init |
Optional |
cool |
Numeric in (0, 1]. Per-iteration temperature decay (default 0.98). |
normalize |
Logical. If |
verbose |
Logical. Print progress every 50 iterations. |
Numeric matrix n_nodes x dim of node coordinates.
edges <- cbind(c(1, 2, 3, 4), c(2, 3, 4, 1)) pos <- cgv_layout_fr(4, edges, n_iter = 200)edges <- cbind(c(1, 2, 3, 4), c(2, 3, 4, 1)) pos <- cgv_layout_fr(4, edges, n_iter = 200)
Same energy model as cgv_layout_fr but with O(n log n) repulsion
approximated through an octree. Suitable for large graphs (10^4+ nodes).
cgv_layout_fr_bh( n_nodes, edges, n_iter = 200L, ideal_len = NULL, theta = 1, cool = 0.98, min_dist = 0.01, seed = NULL, init = NULL, normalize = TRUE )cgv_layout_fr_bh( n_nodes, edges, n_iter = 200L, ideal_len = NULL, theta = 1, cool = 0.98, min_dist = 0.01, seed = NULL, init = NULL, normalize = TRUE )
n_nodes |
Integer. Number of nodes. |
edges |
Two-column integer matrix |
n_iter |
Integer. Number of iterations (default 200). |
ideal_len |
Numeric target edge length. If |
theta |
Barnes-Hut opening angle (default 1.0). Larger = faster, less accurate. |
cool |
Per-iteration temperature decay (default 0.98). |
min_dist |
Minimum distance clamp for repulsion / edge attraction (default 0.01). Avoids division-by-zero when nodes coincide. |
seed |
Optional integer for reproducible initialization. |
init |
Optional |
normalize |
Logical. If |
Numeric matrix n_nodes x 3 of node coordinates.
Pipes raw RGB frames from the live canvas into ffmpeg, which
encodes them on the fly. The recording runs in the background while the
user keeps interacting with the viewer (mouse, keyboard).
cgv_record_start( viewer, file, fps = 30L, duration = NA_real_, ffmpeg_args = NULL )cgv_record_start( viewer, file, fps = 30L, duration = NA_real_, ffmpeg_args = NULL )
viewer |
External pointer from |
file |
Output path; extension determines the format. |
fps |
Frames per second (default 30). |
duration |
Optional cap in seconds; |
ffmpeg_args |
Optional extra ffmpeg flags spliced before the output
path (e.g. |
Requires ffmpeg on PATH. The container/codec is chosen by the
file extension (.mp4 / .mkv / .webm / etc.).
Frames are captured at the requested fps; if the rendering loop
produces frames faster, extras are dropped.
The recording is automatically stopped when the viewer is closed,
cgv_record_stop() is called, or the optional duration
elapses.
No return value, called for side effects: stores the recording
parameters on the viewer; the ffmpeg pipe is opened lazily on the
first rendered frame. Returns NULL invisibly.
Closes the ffmpeg pipe (which finalises the output file) and frees the recording state on the viewer.
cgv_record_stop(viewer)cgv_record_stop(viewer)
viewer |
External pointer from |
Invisibly, an integer vector c(frames, fps) reporting how
many frames were written.
Starts the rendering loop.
cgv_run(viewer, n_frames = 0L)cgv_run(viewer, n_frames = 0L)
viewer |
External pointer returned by |
n_frames |
Maximum number of frames to render. |
No return value, called for side effects: drives the render
loop. Blocks until the window is closed (interactive mode,
n_frames = 0) or until exactly n_frames frames have
been rendered (scripted/offscreen mode). Returns NULL invisibly.
Provide the full graph (or a subgraph) as adjacency data with optional node colors, sizes, and colormap.
cgv_set_graph( viewer, nodes, edges, positions = NULL, node_values = NULL, node_colors = NULL, node_sizes = NULL, cmap = 6L )cgv_set_graph( viewer, nodes, edges, positions = NULL, node_values = NULL, node_colors = NULL, node_sizes = NULL, cmap = 6L )
viewer |
External pointer returned by |
nodes |
Integer vector of node IDs. |
edges |
Two-column integer matrix (from, to), 1-based. |
positions |
Nx3 numeric matrix of 3D coordinates (optional; linear if NULL). |
node_values |
Numeric vector of length N for automatic coloring via colormap
(e.g. BFS depth, group id). Ignored if |
node_colors |
Nx4 integer matrix (RGBA 0-255) for explicit node colors.
Takes priority over |
node_sizes |
Numeric vector of length N for point sizes (default 10). |
cmap |
Integer colormap id (default 6 = viridis). Common values: 5 = plasma, 6 = viridis, 7 = inferno, 8 = magma. |
No return value, called for side effects: uploads the node and
edge buffers to the GPU and caches node positions on the viewer for
subsequent cgv_fly_to / picking calls. Returns NULL
invisibly.
Controls how many hops from the current focus node are rendered.
cgv_set_visibility(viewer, depth = 10L)cgv_set_visibility(viewer, depth = 10L)
viewer |
External pointer returned by |
depth |
Integer number of hops (default 10). |
No return value, called for side effects: updates the
visibility depth used to filter rendered nodes by BFS distance.
Returns NULL invisibly.
Opens a Vulkan-powered 3D window for interactive graph visualization.
cgv_viewer(width = 1280L, height = 720L, title = "cgvR", offscreen = FALSE)cgv_viewer(width = 1280L, height = 720L, title = "cgvR", offscreen = FALSE)
width |
Window width in pixels. |
height |
Window height in pixels. |
title |
Window title. |
offscreen |
If |
An external pointer to the viewer object (invisibly).