R/zzz_reachability.R

# Normalize the matrix orientation before calling the C++ reachability kernel.
# The kernel interprets the matrix as row-stochastic, while a markovchain
# object may represent transitions by columns when byrow = FALSE.
setMethod("is.accessible", c("markovchain", "missing", "missing"),
  function(object, from, to) {
    if (!object@byrow) {
      object@transitionMatrix <- t(object@transitionMatrix)
      object@byrow <- TRUE
    }

    .reachabilityMatrixRcpp(object)
  }
)

Try the markovchain package in your browser

Any scripts or data that you put into this service are public.

markovchain documentation built on Oct. 10, 2026, 9:07 a.m.