\HeaderA{communities}{Common functions supporting community detection algorithms}{communities}
\aliasA{community.to.membership}{communities}{community.to.membership}
\keyword{graphs}{communities}
\begin{Description}\relax
\code{community.to.membership} takes a merge matrix, a typical result
of community structure detection algorithms and creates a membership
vector by performing a given number of merges in the merge matrix.
\end{Description}
\begin{Usage}
\begin{verbatim}
community.to.membership(graph, merges, steps, membership=TRUE, csize=TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{graph}] The graph to which the merge matrix belongs.
\item[\code{merges}] The merge matrix, see
e.g. \code{\LinkA{walktrap.community}{walktrap.community}} for the exact format.
\item[\code{steps}] The number of steps, ie. merges to be performed.
\item[\code{membership}] Logical scalar, whether to include the membership
vector in the result.
\item[\code{csize}] Logical scalar, whether to include the sizes of the
communities in the result.
\end{ldescription}
\end{Arguments}
\begin{Value}
A named list with two members:
\begin{ldescription}
\item[\code{membership}] The membership vector.
\item[\code{csize}] A numeric vector giving the sizes of the communities.
\end{ldescription}
\end{Value}
\begin{Author}\relax
Gabor Csardi \email{csardi@rmki.kfki.hu}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{walktrap.community}{walktrap.community}},
\code{\LinkA{edge.betweenness.community}{edge.betweenness.community}},
\code{\LinkA{fastgreedy.community}{fastgreedy.community}},
\code{\LinkA{spinglass.community}{spinglass.community}} for various community detection
methods.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
g <- graph.full(5) %du% graph.full(5) %du% graph.full(5)
g <- add.edges(g, c(0,5, 0,10, 5, 10))
wtc <- walktrap.community(g)
community.to.membership(g, wtc$merges, steps=12)
\end{ExampleCode}
\end{Examples}

