% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/create_monolayer_network.R
\name{create_monolayer_network}
\alias{create_monolayer_network}
\title{Creates a monolayer network object.}
\usage{
create_monolayer_network(
  x,
  directed = NULL,
  bipartite = NULL,
  group_names = c("set_cols", "set_rows"),
  node_metadata = NULL
)
}
\arguments{
\item{x}{input data in the format of a matrix, edge list or an igraph object.}

\item{directed}{Is the network directed?}

\item{bipartite}{Is the network bipartite? Ignored when the input is an igraph object.}

\item{group_names}{For bipartite networks: name of the groups in the columns
and rows, respectively (e.g., parasites and hosts).}

\item{node_metadata}{Following the igraph method of \code{graph_from_data_frame}.
First column must be have names matching those in x.}
}
\value{
A \code{monolayer} object.
}
\description{
Automatically identifies if the input is a matrix or an edge list and creates
a \code{monolayer} object.
}
\details{
Converts between edge list and matrix formats and creates a
  monolayer object. It a wrapper function for
  \code{list_to_matrix, matrix_to_list_unipartite, matrix_to_list_bipartite}. Node metadata can only be included with an edge list input.
}
\examples{
library(igraph)

# A bipartite network from package bipartte
x <- create_monolayer_network(bipartite::memmott1999, bipartite = TRUE,
directed = FALSE, group_names = c('Animals','Plants'))

# A bipartite network as an igraph object

# Generate a random bipartite network in igraph
g <- igraph::sample_bipartite(10,16,p=0.3, type = 'gnp', directed = TRUE, mode = 'in')
V(g)$name <- letters # name the nodes
V(g)$gender <- sample(c('F','M'), size = 26, replace = TRUE) # Add a node attribute
E(g)$weight=runif(ecount(g)) # Add edge weights
plot(g, layout=layout.bipartite)
create_monolayer_network(g, group_names = c('Parasites','Hosts'))




}
\seealso{
\code{list_to_matrix, matrix_to_list_unipartite, monolayer}.
}
