% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/co-network.R
\name{conetwork}
\alias{conetwork}
\title{Build a co-occurrence network from any field}
\usage{
conetwork(
  data,
  field,
  by = NULL,
  sep = ";",
  counting = "full",
  similarity = "none",
  threshold = 0,
  min_occur = 1L,
  top_n = NULL,
  self_loops = FALSE,
  deduplicate = TRUE,
  format = "edgelist"
)
}
\arguments{
\item{data}{A data frame with column \code{id} and the specified field(s).}

\item{field}{Character. The entity field — determines what the nodes are.}

\item{by}{Character or \code{NULL}. What links the nodes. If \code{NULL} (default),
entities are linked by co-occurring in the same document. If specified,
entities are linked when they share values from the \code{by} field.}

\item{sep}{Character or \code{NULL}. Delimiter for splitting character columns.
Default \code{";"}. Set to \code{NULL} if columns are already list-columns.}

\item{counting}{Character. Counting method. Default \code{"full"}.}

\item{similarity}{Character. Normalization method. Default \code{"none"}.}

\item{threshold}{Numeric. Minimum edge weight. Default 0.}

\item{min_occur}{Integer. Minimum entity frequency. Default 1.}

\item{top_n}{Integer or NULL. Return only the top n edges by weight.
Default NULL (all edges).}

\item{self_loops}{Logical. If \code{TRUE}, include self-loops (an entity linked
to itself). Default \code{FALSE}.}

\item{deduplicate}{Logical. If \code{TRUE} (default), each \verb{(paper, entity)}
pair is counted at most once — duplicate entries in the source data
(e.g., the same author listed twice on a paper) are treated as one
occurrence. Set to \code{FALSE} to count every raw occurrence.}

\item{format}{Character. Output format:
\describe{
\item{\code{"edgelist"}}{Default. A \code{bibnets_network} data frame with
columns \code{from}, \code{to}, \code{weight}, \code{count}.}
\item{\code{"gephi"}}{Gephi-ready data frame: \code{Source}, \code{Target},
\code{Weight}, \code{Count}, \code{Type}.}
\item{\code{"igraph"}}{An igraph graph object (requires igraph).}
\item{\code{"cograph"}}{A cograph_network object (requires cograph).}
\item{\code{"matrix"}}{A sparse adjacency matrix.}
}}
}
\value{
Depends on \code{format}: a \code{bibnets_network} data frame (default),
a Gephi-ready data frame, an igraph graph, a cograph_network, or a
sparse matrix.
}
\description{
With one field, entities are linked when they co-occur in the same
document. With \code{by}, entities are linked when they share values of the
\code{by} field across documents.
}
\details{
Fields can be list-columns (already split) or character columns with
delimiters (auto-split via \code{sep}).
}
\examples{
data(biblio_data)

# Co-occurrence: keywords appearing in the same document
conetwork(biblio_data, "keywords")

# Authors linked by shared keywords
conetwork(biblio_data, "authors", by = "keywords")

# Keywords linked by shared authors
conetwork(biblio_data, "keywords", by = "authors")

# Journals linked by shared references (= journal coupling)
conetwork(biblio_data, "journal", by = "references", similarity = "cosine")

# Auto-splits semicolon-delimited string columns
d <- data.frame(id = 1:3, tags = c("ml; dl; nlp", "ml; cv", "dl; cv"))
conetwork(d, "tags")
}
