% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/graph.R
\name{Graph}
\alias{Graph}
\title{Phase-Type Distribution Graph}
\description{
R6 class wrapping the Python Graph class for phase-type distributions.
Provides methods for graph construction, PDF/PMF computation, reward
transformation, and moment computation.
}
\details{
This class provides an R interface to the Python phasic.Graph class.
Graphs represent phase-type distributions using vertices (states) and
weighted edges (transitions).
}
\section{Methods}{
\subsection{Public methods}{
\itemize{
\item \href{#method-Graph-new}{\code{Graph$new()}}
\item \href{#method-Graph-starting_vertex}{\code{Graph$starting_vertex()}}
\item \href{#method-Graph-find_or_create_vertex}{\code{Graph$find_or_create_vertex()}}
\item \href{#method-Graph-vertices_length}{\code{Graph$vertices_length()}}
\item \href{#method-Graph-pdf}{\code{Graph$pdf()}}
\item \href{#method-Graph-dph_pmf}{\code{Graph$dph_pmf()}}
\item \href{#method-Graph-reward_transform}{\code{Graph$reward_transform()}}
\item \href{#method-Graph-moments}{\code{Graph$moments()}}
\item \href{#method-Graph-serialize}{\code{Graph$serialize()}}
\item \href{#method-Graph-set_py_graph}{\code{Graph$set_py_graph()}}
\item \href{#method-Graph-get_py_graph}{\code{Graph$get_py_graph()}}
\item \href{#method-Graph-clone}{\code{Graph$clone()}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Graph-new"></a>}}
\if{latex}{\out{\hypertarget{method-Graph-new}{}}}
\subsection{Method \code{new()}}{
Create a new Graph object
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Graph$new(
  state_length = NULL,
  callback = NULL,
  parameterized = FALSE,
  nr_samples = NULL
)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{state_length}}{Integer length of state vector}

\item{\code{callback}}{Optional R function for graph construction}

\item{\code{parameterized}}{Logical, whether edges are parameterized (default FALSE)}

\item{\code{nr_samples}}{Integer, number of samples for callback-based construction}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
A new Graph object
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Graph-starting_vertex"></a>}}
\if{latex}{\out{\hypertarget{method-Graph-starting_vertex}{}}}
\subsection{Method \code{starting_vertex()}}{
Get the starting vertex of the graph
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Graph$starting_vertex()}\if{html}{\out{</div>}}
}

\subsection{Returns}{
Vertex object
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Graph-find_or_create_vertex"></a>}}
\if{latex}{\out{\hypertarget{method-Graph-find_or_create_vertex}{}}}
\subsection{Method \code{find_or_create_vertex()}}{
Find or create a vertex with given state
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Graph$find_or_create_vertex(state)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{state}}{Integer vector representing the state}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
Vertex object
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Graph-vertices_length"></a>}}
\if{latex}{\out{\hypertarget{method-Graph-vertices_length}{}}}
\subsection{Method \code{vertices_length()}}{
Get number of vertices in graph
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Graph$vertices_length()}\if{html}{\out{</div>}}
}

\subsection{Returns}{
Integer number of vertices
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Graph-pdf"></a>}}
\if{latex}{\out{\hypertarget{method-Graph-pdf}{}}}
\subsection{Method \code{pdf()}}{
Compute PDF at given time(s)
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Graph$pdf(time, granularity = 0L)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{time}}{Numeric vector of time points}

\item{\code{granularity}}{Integer granularity for uniformization (default 0 = auto)}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
Numeric vector of PDF values
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Graph-dph_pmf"></a>}}
\if{latex}{\out{\hypertarget{method-Graph-dph_pmf}{}}}
\subsection{Method \code{dph_pmf()}}{
Compute PMF for discrete phase-type distribution
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Graph$dph_pmf(jumps)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{jumps}}{Integer vector of jump counts}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
Numeric vector of PMF values
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Graph-reward_transform"></a>}}
\if{latex}{\out{\hypertarget{method-Graph-reward_transform}{}}}
\subsection{Method \code{reward_transform()}}{
Perform reward transformation
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Graph$reward_transform(rewards)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{rewards}}{Numeric vector of rewards (one per vertex)}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
New Graph object with reward transformation applied
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Graph-moments"></a>}}
\if{latex}{\out{\hypertarget{method-Graph-moments}{}}}
\subsection{Method \code{moments()}}{
Compute moments of the distribution
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Graph$moments(power, rewards = NULL)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{power}}{Integer number of moments to compute}

\item{\code{rewards}}{Optional numeric vector of rewards}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
Numeric vector of moments
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Graph-serialize"></a>}}
\if{latex}{\out{\hypertarget{method-Graph-serialize}{}}}
\subsection{Method \code{serialize()}}{
Serialize graph to JSON
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Graph$serialize()}\if{html}{\out{</div>}}
}

\subsection{Returns}{
JSON string representation
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Graph-set_py_graph"></a>}}
\if{latex}{\out{\hypertarget{method-Graph-set_py_graph}{}}}
\subsection{Method \code{set_py_graph()}}{
Set internal Python graph object (for internal use)
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Graph$set_py_graph(py_graph)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{py_graph}}{Python Graph object}
}
\if{html}{\out{</div>}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Graph-get_py_graph"></a>}}
\if{latex}{\out{\hypertarget{method-Graph-get_py_graph}{}}}
\subsection{Method \code{get_py_graph()}}{
Get internal Python graph object (for internal use)
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Graph$get_py_graph()}\if{html}{\out{</div>}}
}

\subsection{Returns}{
Python Graph object
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-Graph-clone"></a>}}
\if{latex}{\out{\hypertarget{method-Graph-clone}{}}}
\subsection{Method \code{clone()}}{
The objects of this class are cloneable with this method.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Graph$clone(deep = FALSE)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{deep}}{Whether to make a deep clone.}
}
\if{html}{\out{</div>}}
}
}
}
