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

\method{global_persistence}{default}(x, edge_list, weights = NULL, membership, H0 = 0, ...)

\method{global_persistence}{igraph}(x, membership, H0 = 0, ...)
}
\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{membership}, \code{H0}).}

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

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

\item{membership}{Integer vector of vertex cluster assignments: \code{x_i = k} if \code{i in C_k}.}

\item{H0}{Optional numeric value in \eqn{[0, 1]}, or \code{NULL}. Default is \code{0}.}
}
\value{
A list with two elements:
\describe{
\item{score}{The global persistence of the partition.}
\item{clusters_value}{The local persistence of each cluster. A value of \code{NaN}
indicates that cluster \eqn{C_k} is empty in the input \code{membership}.}
}
}
\description{
Given a partition of the graph vertices, calculates the global persistence
as the sum of the local persistences of the individual clusters.
Persistence can be either null-adjusted or probability-based.
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)
mem <- c(1, 1, 1, 1, 2, 2, 2)
global_persistence(x = vertex, edge_list = edge_list, membership = mem)

# --- EXAMPLE 2: igraph input ---
if (requireNamespace("igraph", quietly = TRUE)) {
  g <- igraph::make_ring(10)
  mem <- c(rep(1, 5), rep(2, 5))
  global_persistence(g, membership = mem)
}

}
