\HeaderA{Graphs from adjacency lists}{Create graphs from adjacency lists}{Graphs from adjacency lists}
\aliasA{graph.adjlist}{Graphs from adjacency lists}{graph.adjlist}
\keyword{graphs}{Graphs from adjacency lists}
\begin{Description}\relax
An adjacency list is a list of numeric vectors, containing
the neighbor vertices for each vertex. This function creates an igraph
graph object from such a list.
\end{Description}
\begin{Usage}
\begin{verbatim}
graph.adjlist(adjlist, directed = TRUE, duplicate = TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{adjlist}] The adjacency list. It should be consistent, i.e. the
maximum throughout all vectors in the list must be less than the
number of vectors (=the number of vertices in the graph). Note that
the list is expected to be 0-indexed.
\item[\code{directed}] Logical scalar, whether or not to create a directed
graph.
\item[\code{duplicate}] Logical scalar. For undirected graphs it gives
whether edges are included in the list twice. E.g. if it is
\code{TRUE} then for an undirected \code{\{A,B\}} edge
\code{graph.adjlist} expects \code{A} included in the neighbors of
\code{B} and \code{B} to be included in the neighbors of \code{A}.

This argument is ignored if \code{directed} is \code{TRUE}.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Adjacency lists are handy if you intend to do many (small)
modifications to a graph. In this case adjacency lists are more
efficient than igraph graphs.

The idea is that you convert your graph to an adjacency list by
\code{\LinkA{get.adjlist}{get.adjlist}}, do your modifications to the graphs and
finally create again an igraph graph by calling \code{graph.adjlist}.
\end{Details}
\begin{Value}
An igraph graph object.
\end{Value}
\begin{Author}\relax
Gabor Csardi \email{csardi@rmki.kfki.hu}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{get.edgelist}{get.edgelist}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## Directed
g <- graph.ring(10, dir=TRUE)
al <- get.adjlist(g, mode="out")
g2 <- graph.adjlist(al)
graph.isomorphic(g, g2)

## Undirected
g <- graph.ring(10)
al <- get.adjlist(g)
g2 <- graph.adjlist(al, dir=FALSE)
graph.isomorphic(g, g2)
ecount(g2)
g3 <- graph.adjlist(al, dir=FALSE, duplicate=FALSE)
ecount(g3)
is.multiple(g3)
\end{ExampleCode}
\end{Examples}

