| lap_animate | R Documentation |
Produce an interactive bipartite-graph animation showing how a chosen linear-assignment algorithm transforms the matching over time. The result is an htmlwidget suitable for use in R Markdown, Quarto, pkgdown vignettes, Shiny apps, or standalone HTML output.
lap_animate(
cost,
method = "hungarian",
maximize = FALSE,
width = NULL,
height = NULL,
elementId = NULL,
...
)
cost |
Numeric cost matrix. Rows = workers/sources, columns = jobs/targets.
|
method |
Character; the algorithm to animate. Must match one of the
methods registered for animation (see |
maximize |
Logical; if |
width, height |
Optional explicit widget dimensions (pixels or CSS units). |
elementId |
Optional DOM id for the widget container. |
... |
Algorithm-specific extra arguments forwarded to the trace
function (e.g. |
This is a teaching interface. It runs a slower R reference implementation
that emits a state trace at every step, then plays it back in the browser.
For production solving, use assignment() or lap_solve() which call the
fast C++ backends.
An htmlwidget object.
Animation support is added incrementally. Call animated_methods() to see
which method strings currently have a registered trace.
assignment() for production solving, lap_solve() for the tidy
interface.
## Not run:
cost <- matrix(c(4, 2, 5,
3, 3, 6,
7, 5, 4), nrow = 3, byrow = TRUE)
lap_animate(cost, method = "hungarian")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.