\HeaderA{as.directed}{Convert between directed and undirected graphs}{as.directed}
\aliasA{as.undirected}{as.directed}{as.undirected}
\keyword{graphs}{as.directed}
\begin{Description}\relax
\code{as.directed} converts an undirected graph to
directed, \code{as.undirected} is the opposite, it converts a directed
graph to undirected.
\end{Description}
\begin{Usage}
\begin{verbatim}
as.directed(graph, mode = c("mutual", "arbitrary")) 
as.undirected(graph, mode = c("collapse", "each")) 
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{graph}] The graph to convert.
\item[\code{mode}] Character constant, defines the conversion algorithm. For
\code{as.directed} it can be \code{mutual} or \code{arbitrary}. For
\code{as.undirected} it can be \code{each} or \code{collapse}. See
details below.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Conversion algorithms for \code{as.directed}:
\Itemize{
\item[arbitrary] The number of
edges in the graph stays the same, an arbitrarily directed edge is
created for each undirected edge.
\item[mutual] Two directed edges are created for each undirected
edge, one in each direction.
}

Conversion algorithms for \code{as.undirected}:
\Itemize{
\item[each] The number of edges remains constant, an undirected edge
is created for each directed one, this version might create graphs
with multiple edges.
\item[collapse] One undirected edge will be created for each pair of
vertices which are connected with at least one directed edge, no
multiple edges will be created.
}
\end{Details}
\begin{Value}
A new graph object.
\end{Value}
\begin{Author}\relax
Gabor Csardi \email{csardi@rmki.kfki.hu}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{simplify}{simplify}} for removing multiple and/or loop edges
from a graph.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
g <- graph.ring(10)
as.directed(g, "mutual")
g2 <- graph.star(10)
as.undirected(g)
\end{ExampleCode}
\end{Examples}

