% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cluster_milano.R
\name{cluster_milano}
\alias{cluster_milano}
\alias{cluster_milano.default}
\alias{cluster_milano.igraph}
\title{cluster_milano}
\usage{
cluster_milano(x, ...)

\method{cluster_milano}{default}(
  x,
  edge_list,
  weights = NULL,
  membership = NULL,
  H0 = TRUE,
  seed = NULL,
  tol = NULL,
  max_level = 0L,
  ...
)

\method{cluster_milano}{igraph}(
  x,
  membership = NULL,
  H0 = TRUE,
  seed = NULL,
  tol = NULL,
  max_level = 0L,
  ...
)
}
\arguments{
\item{x}{An integer or character vector representing the graph vertices,
OR an object of class \code{igraph}.}

\item{...}{Additional arguments passed to specific methods (e.g., \code{edge_list},
\code{weights}, \code{tol}, \code{max_level}, etc.).}

\item{edge_list}{Integer matrix with two columns representing the graph edge list.}

\item{weights}{Numeric vector of positive edge weights. If \code{NULL}, all weights default to 1.}

\item{membership}{Integer vector representing the starting partition: \code{x_i = k} if \code{i in C_k}.
If \code{NULL}, each vertex starts in its own cluster.}

\item{H0}{Logical value. Default is \code{TRUE}.
If \code{TRUE}, returns the null-adjusted persistence.
If \code{FALSE}, returns the persistence probability.}

\item{seed}{Non-negative integer seed for the random number generator.
If \code{NULL}, an internal default is used.}

\item{tol}{Optional numeric tolerance for the stopping criterion.
If \code{NULL} (default), an adaptive threshold is calculated dynamically in C++.}

\item{max_level}{Optional integer representing the maximum number of aggregation levels.
If \code{0} (default) or \code{NULL}, the algorithm runs until convergence.}
}
\value{
A list with three elements:
\describe{
\item{membership}{The optimal vertex partition.}
\item{score}{The measure value of the optimal partition.}
\item{seed}{The seed used to generate random numbers.}
}
}
\description{
Calculates the vertex partition with maximum global null-adjusted persistence.
This function is polymorphic: it automatically detects the input type and accepts
either a vertex vector (accompanied by an edge list) or directly an \code{igraph} object.
}
\examples{
library(persistence)

# --- EXAMPLE 1: Standard input (vectors and matrices) ---
edg <- c(1, 2, 1, 3, 1, 4, 2, 3, 3, 4, 4, 5, 5, 6, 5, 7, 6, 7)
edge_list <- matrix(edg, ncol = 2, byrow = TRUE)
vertex <- c(1, 2, 3, 4, 5, 6, 7)
cluster_milano(x = vertex, edge_list = edge_list)

# --- EXAMPLE 2: igraph input ---
if (requireNamespace("igraph", quietly = TRUE)) {
  g <- igraph::make_ring(10)
  cluster_milano(g)
}

}
