% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/class-network.R
\name{as_cograph}
\alias{as_cograph}
\alias{to_cograph}
\title{Convert to Cograph Network}
\usage{
as_cograph(x, directed = NULL, simplify = FALSE, ...)

to_cograph(x, directed = NULL, ...)
}
\arguments{
\item{x}{Network input. Can be:
\itemize{
\item A square numeric matrix (adjacency/weight matrix)
\item A data frame with edge list (from, to, optional weight columns)
\item An igraph object
\item A statnet network object
\item A qgraph object
\item A tna object
\item An existing cograph_network object (returned as-is)
}}

\item{directed}{Logical. Force directed interpretation. NULL for auto-detect.}

\item{simplify}{Logical or character. If FALSE (default), every transition
from tna sequence data is a separate edge. If TRUE or a string
("sum", "mean", "max", "min"), duplicate edges are aggregated.}

\item{...}{Additional arguments (currently unused).}
}
\value{
A cograph_network object: a named list with components:
\describe{
\item{\code{nodes}}{Data frame with id, label, and optional layout or metadata columns}
\item{\code{edges}}{Data frame with from, to, weight columns}
\item{\code{directed}}{Logical indicating if network is directed}
\item{\code{weights}}{Full n×n weight matrix when available for matrix/TNA round-trips, or NULL}
\item{\code{data}}{Original estimation data (sequence matrix, edge list, etc.), or NULL}
\item{\code{meta}}{Consolidated metadata list with sub-fields:
\code{source} (input type string),
\code{layout} (layout info list or NULL),
\code{tna} (TNA metadata or NULL), and optionally
\code{splot} (producer-supplied rendering hints read by
\code{\link{splot}})}
\item{\code{node_groups}}{Optional node groupings data frame}
}

A \code{cograph_network} object. See \code{\link{as_cograph}}.
}
\description{
Creates a lightweight cograph_network object from various network inputs.
The resulting object is a named list with all data accessible via \code{$}.
}
\details{
The cograph_network format is designed to be:
\itemize{
\item Lean: Only essential data stored, computed values derived on demand
\item Modern: Uses named list elements instead of attributes for clean \code{$} access
\item Compatible: Works seamlessly with splot() and other cograph functions
}

Producer packages may attach optional plotting hints under
\code{meta$splot}. The recognized fields are \code{renderer} (which cograph
renderer to use), \code{weight} (the edge column or matrix to render as
\code{weight}), and \code{defaults} (a named list of renderer arguments).
Entries in \code{defaults} are defaults only — user-supplied arguments to
\code{\link{splot}} always override them. \code{renderer} and \code{weight}
define which view is rendered and are not overridden by plot arguments.

Use getter functions for programmatic access:
\code{\link{get_nodes}}, \code{\link{get_edges}}, \code{\link{get_labels}},
\code{\link{n_nodes}}, \code{\link{n_edges}}

Use setter functions to modify:
\code{\link{set_nodes}}, \code{\link{set_edges}}, \code{\link{set_layout}}
}
\examples{
mat <- matrix(c(0, 1, 1, 1, 0, 1, 1, 1, 0), nrow = 3)
net <- as_cograph(mat)
get_nodes(net)
get_edges(net)
splot(net)
mat <- matrix(c(0, 1, 1, 1, 0, 1, 1, 1, 0), nrow = 3)
net <- to_cograph(mat)
}
\seealso{
\code{\link{get_nodes}} to extract the nodes data frame,
\code{\link{get_edges}} to extract edges as a data frame,
\code{\link{n_nodes}} and \code{\link{n_edges}} for counts,
\code{\link{is_directed}} to check directedness,
\code{\link{splot}} for plotting
}
