\section{Introduction}

In \cite{AMR}, Antunovi\'{c}, Mossel and R\'{a}cz introduced a model for preferential attachment graphs where each vertex is of one of a number of types, which may, for example, be thought of as brand preferences.  Each vertex chooses its type based on the types of its neighbours when it joins the network.  In this paper, we will concentrate on the setting with two types, which we refer to as ``red'' and ``blue'', and standard preferential attachment. Antunovi\'{c}, Mossel and R\'{a}cz \cite{AMR} showed that in this setting the proportion of red vertices converges to a limit. In the ``linear model'' this limit is distributed with full support on $[0,1]$, whereas in non-linear models there are finitely many possible limits corresponding to stable zeros of a particular polynomial $P$, defined later, which depends on the type assignment rule.

The purpose of this paper is to extend the analysis of \cite{AMR} to preferential attachment models with community structure.  The model we use is the model for geometric preferential attachment graphs in Jordan \cite{geopref9}, in the special case where the space $S$ the graphs are embedded in is a finite set; each element of $S$ can then be thought of as a community, as described by Hajek and Sankagiri in \cite{hajek2018}.

A natural question in this setting is whether different communities can show different limiting behaviour for the proportions of types within them.  We will answer this question in the affirmative, showing (Theorem \ref{different}) that where the polynomial $P$ defined by the type assignment rule has multiple stable zeros there is, assuming some natural conditions on the type assignment rule, positive probability of different limits in different communities if the interaction between the communities is sufficiently weak.

We will also show (Theorems \ref{same} and \ref{determinant}) that, again under some natural conditions on the interaction between the communities and the type assignment rule, this does not occur if the polynomial $P$ has only one stable zero (corresponding to only one limit having positive probability in the model of \cite{AMR}) and that in this the proportions of red in each community will all converge to the same limit.  However, we will also show some examples, with perhaps less natural choices of community interaction and type assignment rule, where multiple limits are possible even in this case.

Based on the results in \cite{AMR} for a single community, it might be expected that for any stable zero of the polynomial $P$ there would be positive probability that there would be convergence of the proportions of red vertices in each community to that zero.  It turns out that in the multi community set-up this is not necessarily the case, and indeed we will show an example (Proposition \ref{threecycle}) where the proportions of types in the different communities almost surely do not converge to limits.  However, we will give a result (Theorem \ref{stable}) with an extra condition on $P$ in the neighbourhood of the zero which ensures that there is positive probability of all communities converging to it.

Finally, we will show (Theorem \ref{linear}) that, as long as there are enough non-zero interactions between communities, in the linear model (where $P$ is the zero polynomial) convergence to different limits does not occur and all communities synchronise to the same random limit; compare the synchronisation of P\'{o}lya urns with a network structure found in Dai Pra, Louis and Minelli \cite{dai2014}.

We mention some related work and some possible extensions.  The broadcasting problem studied by Addagio-Berry, Devroye, Lugosi and Velona \cite{broadcasting} on the preferential attachment tree is a special case of the model of \cite{AMR}, while Backhausz and Rodner \cite{BR19} consider a model where it is the edges rather than the vertices which have types.  The model of \cite{geopref9} is more generally a geometric preferential attachment model with vertices embedded in a metric space $S$ as in Flaxman, Frieze and Vera \cite{FFV1,FFV2} and Manna and Sen \cite{manna}.  Given our results for the case where $S$ is finite, a natural question is whether different limits may be possible in different parts of $S$ when $S$ is an uncountable metric space such as a torus.  A degenerate case of geometric preferential attachment is the online nearest neighbour graph, as discussed in \cite{jordanwade} and \cite{manna} (where it is considered as the ``$\alpha=-\infty$'' case).  A simple type assignment process on the online nearest neighbour graph, where each vertex takes the type of its nearest neighbour when it joins the graph, is equivalent to the partitions model studied by Aldous in \cite{aldouspartitions}, where it is shown that the process converges in a suitable sense to a random partition of the underlying set; this might suggest that similar phenomena might occur for at least some geometric preferential attachment models.

The structure of the paper is as follows.  We define our framework in section \ref{sect:def} and state our results in section \ref{sect:results}, with proofs of the results in section \ref{sect:proofs}.  Finally in section \ref{examples} we consider some examples which illustrate our results, show some simulations, and give some more detailed calculations which are specific to those examples.

\section{Definitions and notation}\label{sect:def}
\subsection{Graph model}
Our graph model is the model of \cite{geopref9} with the space $S$ considered to be a finite set, the elements each corresponding to a community, with $N=|S|$ being the number of communities.  Each vertex is assigned to an element of $S$ according to a probability measure $\mu$ independently of other vertices and of the growth of the graph before it is added. A parameter $m$ governs the number of new connections formed by each vertex as it joins the graph.

In addition, there is an attractiveness function, defined by an $N\times N$ matrix $A$ with entries $(\alpha_{x,y})_{x,y\in S}$ such that the relative attractiveness of an existing vertex in community $x$ to a new vertex in community $y$ is $\alpha_{x,y}\geq 0$.  (In many cases, $A$ will be a symmetric matrix, but this is not necessary in \cite{geopref9}.)  We allow an individual attractiveness coefficient $\alpha_{x,y}$ to be $0$, in which case a new vertex in community $y$ will never attach to a vertex in community $x$ (though if $\alpha_{x,y}>0$ edges may form between the two communities in the opposite way). However, for each community $y$ we require $\sum_x \alpha_{x,y}>0$, since a new vertex in community $y$ must attach somewhere. 

The preferential attachment graph evolves from an initial graph $G_0$, with $n_0$ vertices, such that $G_0$ contains at least one vertex in each community and all vertices have positive degree. The graph $G_{t+1}$ is produced from $G_t$ by creating a new vertex $v_{t+1}$ and assigning it to a community $c(v_{t+1})$. We then choose $m$ existing vertices independently at random (with replacement), with the probability of choosing a vertex $v_s$ being 
\begin{equation}\label{attachment}\frac{\alpha_{c(v_s),c(v_{t+1})}\deg_{G_t}(v_s)}{\sum_{u\in V(G_t)}\alpha_{c(u),c(v_{t+1})}\deg_{G_t}(u)},
\end{equation}
and form edges from $v_{t+1}$ to the $m$ vertices chosen (note that this may involve multiple edges between the same pair of vertices).  For notational convenience we assume the initial graph $G_0$ has $mn_0$ edges.

\subsection{Type assignment}
After joining the graph and forming edges, each vertex chooses one of two types, which we refer to as ``red'' and ``blue''. The choice of type is based on the types of its neighbours according to some rule, which may be random. This formulation allows the same type assignment rules as in \cite{AMR} to be considered, and we will use the same notation for the type assignment mechanism; in particular in the case with two types the probability that a new vertex becomes red, conditional on having $k$ red neighbours, is $p_k$.  (Because the new vertex makes $m$ connections in total, the probability that a new vertex with $k$ blue neighbours becomes blue is $1-p_{m-k}$. Type assignment mechanisms with $p_k=1-p_{m-k}$ thus have symmetry between the two types.)  

The special case where $p_k=\frac{k}{m}$ for all $k$ is referred to as the \emph{linear model} in \cite{AMR}. The model studied in \cite{AMR} is as described above but with the graph growing according to a standard preferential attachment model, specifically the \emph{independent model} described in \cite{bergerpa}, which is the special case of the model of \cite{geopref9} with only one community;  we will refer to it in this paper as the \emph{single community} model.

\begin{rem}It is of course possible to consider a version of this model with more than two types, and this was considered in section 3 of \cite{AMR}, although that paper focussed mainly on the two type case.  With more than two types there is potential for more complicated behaviour, and Haslegrave and Jordan \cite{threetypes} gave an example with non-convergence in that case.  We might therefore expect that there are interesting examples with multiple communities and more than two types, but we leave this for future work and focus on two types in this paper.\end{rem}

We will associate the rule given by $p_0,\cdots,p_m$ with the polynomial given by 
\[R(z)=\sum_{i=0}^m\binom miz^i(1-z)^{m-i}p_i,\]
that is, $R(z)$ is the probability of a vertex becoming red if its neighbours are independently red with probability $z$. 

This polynomial allows us to describe the behaviour of the single-community model. Except for the linear model where $R(z)\equiv z$, the possible limits for the proportion of red vertices are the fixed points of $R$; in the linear model the limit is a random variable with full support on $(0,1)$. This was proved in \cite{AMR}, although they instead considered the zeroes of $P(z)=(R(z)-z)/2$.

To understand the possible limits for the single community model further, for a fixed point $z\in (0,1)$ of $R$ we classify it as \emph{stable} if there exists $\eps>0$ such that $R(y)>y$ for $y\in (z-\eps,z)$ and $R(y)<y$ for $y\in (z,z+\eps)$, as \emph{unstable} if there exists $\eps>0$ such that $R(y)<y$ for $y\in (z-\eps,z)$ and $R(y)>y$ for $y\in (z,z+\eps)$, and as a \emph{touchpoint} if there exists $\eps>0$ such that $R(y)-y$ is either strictly positive or strictly negative on $(z-\eps,z)\cup(z,z+\eps)$.  Similarly $z=0$ is a stable fixed point of $R$ if $R(0)=0$ and there exists $\eps>0$ such that $R(y)<y$ for $y\in (0,\eps)$, and is an unstable fixed point of $R$ if $R(0)=0$ and there exists $\eps>0$ such that $R(y)>y$ if $y\in (0,\eps)$; similar definitions apply to a fixed point at $z=1$. We say that a stable fixed point $z$ is \emph{linearly stable} if the derivative $R'(z)<1$, and that an unstable fixed point $z$ is \emph{linearly unstable} if $R'(z)>1$. It is shown in \cite{AMR} that in the single community model the proportion of red edge-ends converges almost surely and that the limit is either a stable fixed point or a touchpoint of $R$, with all such points having positive probability of being the limit.

\section{Results}\label{sect:results}

Our results are concerned with the limiting proportion of red edge-ends in each community (if the limit exists). Equivalently this is the probability that a vertex
selected according to \eqref{attachment} is red, conditional on it being in that community, and as a result almost sure convergence of the proportions of edge ends in each community which are red implies the same for proportions of vertices in each community.

Write $\hier[Z]ni$ for the proportion of edge-ends in community $i$ at time $n$ which are at red vertices, that is 
\[\hier[Z]ni=\frac{\sum_{v\text{ red, }c(v)=i}\deg_{G_n}(v)}{\sum_{v:c(v)=i}\deg_{G_n}(v)}.
\]

Our first result shows that under certain conditions we do get positive probability of different limits in different communities.  It will be useful to consider the following family of attractiveness matrices: given a matrix $A_1$, with all diagonal elements positive, let $A_0$ be a diagonal matrix whose diagonal elements are the same as those of $A_1$, and then for $\theta>0$ define $A_{\theta}=(1-\theta)A_0+\theta A_1$; changing the value of $\theta$ allows tuning of the relative strength of the inter-community and intra-community interactions.  Then the following theorem shows that for sufficiently small but positive $\theta$, there is positive probability that the proportion of red edge ends in community $1$ converges to a limit close to $z_1$ while the proportion of red edge ends in community $2$ converges to a limit close to $z_2$.

\begin{thm}\label{different}Assume that the polynomial $R$ has two distinct linearly stable fixed points, $z_1$ and $z_2$.  Then for any choice of interaction matrix $A_1$, and any $\eps>0$, there exists $\theta_\eps>0$ such that for $\theta<\theta_\eps$ the system with interaction matrix $A_{\theta}$ has positive probability that $\hier[Z]1n\to \tilde z_1$ and $\hier[Z]2n\to\tilde z_2$ as $n\to\infty$, where $\abs{z_1-\tilde z_1},\abs{z_2-\tilde z_2}<\eps$.

In particular, there is some $\theta_{\mathrm{crit}}>0$ such that for $\theta<\theta_{\mathrm{crit}}$ there is positive probability of convergence to different limits.\end{thm} 

Theorem \ref{different} cannot in general be extended to the case where $R$ has one stable fixed point and one touchpoint, even though in this case the single-community model has more than one possible limit.  
\begin{prop}\label{touchpoint}
	Suppose that the polynomial $R$ has a unique stable fixed point $z^*$, and some touchpoints. Let $A_1$ be any interaction matrix with all entries positive. Then for $\theta$ sufficiently small, in the the system with interaction matrix $A_{\theta}$ convergence to different limits has probability zero.
\end{prop}
Examples of this type where different limits having both probability zero and positive probability will be considered in section \ref{examples}.

Our second main result gives some situations where the communities will all have the same limit.  


\begin{thm}\label{same}
	Assume that $z^*$ is the only fixed point of $R$ in $[0,1]$, except possibly for linearly unstable fixed points at $0$ and/or $1$. 
	\begin{enumerate}
		\item Suppose that the type assignment rule is such that the only fixed points of $R(R(z))$ in $[0,1]$ are the fixed points of $R(z)$.
		Then for all communities $i$ we have $\hier[Z]ni \to z^*$ as $n\to\infty$, almost surely.
		\item Conversely, suppose that the type assignment rule is such that $R(R(z))$ has a linearly stable fixed point $\tilde z\neq z^*$.
		Then for the community structure (with two communities) given by 
		\[A=\begin{pmatrix}0 & 1 \\ 1 & 0\end{pmatrix}\]
		and any $\mu_1,\mu_2>0$ with $\mu_1+\mu_2=1$, there is positive probability that there exist $z_1\neq z_2$ such that $\hier[Z]n1\to z_1$ and $\hier[Z]n2\to z_2$.
	\end{enumerate}
\end{thm}

\begin{rem}We note that the condition on the rule in the first part of Theorem \ref{same} is satisfied by any increasing rule for which $R$ has a unique fixed point; here we say that a rule is \emph{increasing} if $R(z)$ is increasing in $z$. Since $R(z)$ may be expressed as $\E(p_K)$ where $K\sim\bin{m,z}$, any rule for which $p_k$ is increasing in $k$ is necessarily an increasing rule; however, the rule being increasing is a strictly weaker condition. For example, when $m=3$ the rule given by $p_0=0, p_1=1,p_2=0,p_3=1$ is increasing, since $R(z)=z^3+3z(1-z)^2$, and so $R'(z)=3(1-2z)^2\geq0$.  All rules considered in \cite{AMR} in fact have $p_k$ increasing in $k$ and thus are increasing rules.
\end{rem}

In the case where there are two communities, we can also give a necessary and sufficient condition on the matrix such that convergence to $z^*$ happens in both communities for any type assignment rule with a single zero, which is stable.
\begin{thm}\label{determinant}
	Consider the two-community case, \ie $S=\{1,2\}$.
	\begin{enumerate}
		\item Suppose $\det A \geq 0$, and the type assignment rule is such that $z^*$ is the only fixed point of $R$ in $[0,1]$, except possibly for linearly unstable fixed points at $0$ and/or $1$.  Then for each $i\in\{1,2\}$ we have $\hier[Z]ni\to z^*$ as $n\to\infty$, almost surely.
		\item Conversely, suppose $\det A < 0$.  Then there exists a type assignment rule such that $R$ has a unique fixed point $z^*\in[0,1]$ but for which there is positive probability that there exist $z_1\neq z_2$ such that $\hier[Z]n1\to z_1$ and $\hier[Z]n2\to z_2$.
	\end{enumerate}
\end{thm}

The methods used to prove Theorem \ref{same} also give the following result, which shows that for stable fixed points of $R$ where $R$ is locally increasing there is positive probability that all communities converge to them; in particular this will apply to any stable fixed point of $R$ when the rule is increasing.

\begin{thm}\label{stable}Let $z^{*}$ be a stable fixed point of the polynomial $R$ such that $R$ is increasing in some neighbourhood of $z^{*}$.  Then there is positive probability that $\hier[Z]ni\to z^*$ for all $i$.
\end{thm}

Some condition beyond stability is necessary in Theorem \ref{stable}.  Indeed, it is possible to find examples which do not even converge to a limit; the following result gives such an example.
\begin{prop}\label{threecycle}
	Let $S=\{1,2,3\}$ and \[A=\begin{pmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 1 & 0 & 0\end{pmatrix}\]
	(representing three communities in a cycle, with each only influenced by the one clockwise of it), with $\mu_i=\frac13$ for $i=1,2,3$.  Let $m$ be an odd integer, and let the $p_k$ be given by the minority rule: $p_k=1$ for $0\leq k \leq \frac{m-1}{2}$ and $p_k=0$ for $\frac{m+1}{2} \leq k \leq m$.  Then for $m\geq 7$ almost surely $\bigl(\hier[Z]1n,\hier[Z]2n,\hier[Z]3n\bigr)$ does not converge to a limit. \end{prop}
Figure \ref{fig:cycling} shows a simulation of proportions of red in each community over time in the framework of Proposition \ref{threecycle} for $m=7$.  It appears that the process is converging instead to a limit cycle.

This example raises the following natural question.
\begin{quest}\label{two-converge}Is there an example with only two communities which fails to converge with positive probability?\end{quest}

Finally, we consider the linear model.  Here we have the following result, which shows that in this setting we do not get different limits in different communities for typical community structures.  To state it we need to consider the directed graph $\Gamma$ whose vertex set is $S$ and which has an edge from $i$ to $j$ if and only if $\alpha_{j,i}>0$.
\begin{thm}\label{linear}
	Assume that $\Gamma$ is such that for any two vertices $i$ and $j$ there is a vertex $h$ such that there are directed paths from both $i$ and $j$ to $h$.  (We allow $h=i$ or $h=j$, and treat any vertex $i$ as having a directed path to itself.)  Then in the linear model with $p_k=\frac{k}{m}$ for all $k$, there exists a random limit $M$ such that $Z^{(n)}_i\to M$ for all $i$.
\end{thm}

\begin{rem}The condition on $\Gamma$ is equivalent to stating that a random walk on $\Gamma$, treating it as a directed graph, has a unique stationary distribution.  It is also equivalent to the directed graph with every edge reversed being \emph{quasi strongly connected} as defined, for example, in Chapter 5 of \cite{MR1157371}.\end{rem}

\begin{figure}[ht]
	\centering
	\scalebox{0.5}{\includegraphics{3-comm-min-of-7-new}}
	\caption{The values of $\hier[Z]t1,\hier[Z]t2,\hier[Z]t3$ in the framework of Proposition \ref{threecycle} with $m=7$ plotted over time (log scale), showing apparent non-convergence.\label{fig:cycling}}
\end{figure}


\section{Proofs}\label{sect:proofs}
\subsection{Stochastic approximation}
The methods used in \cite{AMR} rely heavily on the theory of stochastic approximation, relating the dynamics of the proportion of edge ends which are red to those of the differential equation driven by the polynomial $P(z)=(R(z)-z)/2$.  In this section we show how to set the process up as a multi-dimensional stochastic approximation process and identify the driving vector field; this will be useful for some of our proofs and specific examples.  Note that zeroes of $P$ correspond to fixed points of $R$, and vice versa; we will describe a zero of $P$ as (linearly) stable, (linearly) unstable or a touchpoint according to the behaviour of the corresponding fixed point of $R$.

Let $X^{(n)}_{i,j}$, $i=1,\ldots,N$, $j=1,2$, be the proportion of edge-ends of $G_n$ which are in community $i$ and at a vertex of type $j$; $j=1$ will correspond to red and $j=2$ to blue. Let $\mathbf{X}^{(n)}=\bigl(X^{(n)}_{1,1},X^{(n)}_{1,2},\ldots,X^{(n)}_{N,1},X^{(n)}_{N,2}\bigr)$, and note that this takes values in the set \[\Delta^{2N-1}=\biggl\{(x_{1,1},x_{1,2},\ldots,x_{N,1},x_{N,2})\in \bigl(\R_{\geq 0}\bigr)^{2N}: \sum\nolimits_{i=1}^N (x_{i,1}+x_{i,2})=1\biggr\},\] which is a $(2N-1)$-dimensional set. Write $\hier[Y]ni=\hier[X]n{i,1}+\hier[X]n{i,2}$ for the total proportion of edge-ends in community $i$; note that this means 
$\hier[Y]ni\hier[Z]ni=\hier[X]n{i,1}$.

The probability, conditional on $G_n$ and that the new vertex at time $n+1$ is in community $i$, that a specific edge from that vertex connects to a vertex of type $j$ is $Q_{i,j}(\mathbf{X}^{(n)})$, where for $x\in\Delta^{2N-1}$ we define \[Q_{i,j}(x)=\frac{\sum_{k=1}^N \alpha_{k,i}x_{k,j}}{\sum_{k=1}^N \alpha_{k,i}x_{k,1}+\sum_{k=1}^N \alpha_{k,i}x_{k,2}}.\]  Thus the probability that a new vertex at location $i$ at time $n+1$ becomes red (type $1$) is $R(Q_{i,j}(x))$,
and so the contribution to the expected number of new edge ends of type $1$ at location $i$ at time $n+1$ coming from the new vertex, conditional on $G_n$, can be written $G_{i,1}(\mathbf{X}^{(n)})$, where for $x\in\Delta^{2N-1}$ we define 
$G_{i,1}(x)=m\mu_iR\left(Q_{i,1}(x)\right)$.

Similarly we define $G_{i,2}(x)=m\mu_i (1-R(1-Q_{i,2}(x))$, so that $G_{i,2}(\mathbf{X}^{(n)})$ is the contribution to the expected number of new edge ends of type $2$ at location $i$ at time $n+1$ coming from the new vertex, conditional on $G_n$; this uses the fact that the probability a new vertex is blue (type 2) given that it has $k$ blue neighbours is $1-p_{m-k}$.

The contribution to the expectation coming from the edge ends at the existing vertices is
$H_{i,j}(\mathbf{X}^{(n)})$ where for $x\in\Delta^{2N-1}$ we define \[H_{i,j}(x)=mx_{i,j}\sum_{k=1}^N \mu_k\frac{ \alpha_{i,k}}{\sum_{\ell=1}^{N}\alpha_{\ell,k}\left(x_{\ell,1}+x_{\ell,2}\right)}.\]

Hence we can write \[X^{(n+1)}_{i,j}-X^{(n)}_{i,j}=\gamma_n (F_{i,j}(\mathbf{X}_{n})+\xi^{(n+1)}_{i,j})\] 
where, again for $x\in \Delta^{2N-1}$, \[F_{i,j}(x)=G_{i,j}(x)+H_{i,j}(x)-2m x_{i,j},\] and where $\gamma_n^{-1}=2m(n+n_0+1)$ and the $\xi^{(n+1)}_{i,j}$ are noise terms with $\E(\xi^{(n+1)}_{i,j}\mid\salj_n)=0$, and so $(\mathbf{X}_n)_{n\geq 0}$ is a Robbins-Monro stochastic approximation process as defined in section 4.2 of Bena\"{\i}m \cite{benaim}.  Furthermore, because exactly $2m$ edge ends are added at each time point, each component of the noise term $\xi^{(n+1)}_{i,j}$ is uniformly bounded in modulus by $2m$, which means that we can apply Proposition 4.2 of \cite{benaim} to show that $(\mathbf{X}_n)_{n\geq 0}$ is an asymptotic pseudotrajectory of the vector field on $\Delta^{2N-1}$ driven by $F$.

From results in \cite{geopref9}, for each $i \in \{1,\ldots,N\}$ the limit as $n\to\infty$ of the proportion of edge ends in community $i$, $X^{(n)}_{1,1}+X^{(n)}_{1,2}$, almost surely converges to a particular limit $\nu_i$, where the $\nu_i$ are the unique solution satisfying $\nu_i\in[0,1]$ for all $i$ and $\sum_{i=1}^N \nu_i=1$ to the equations \begin{equation}\label{edgeendlim}\nu_i=\frac12 \mu_i+\frac12 \sum_{j=1}^N\mu_j\frac{a_{i,j}\nu_j}{\sum_{k=1}^N a_{k,j}\nu_k}.\end{equation}  The consequence of this result for our situation is that the limit set of $(\mathbf{X}_n)$ must be contained within the set \[\Delta_{\nu}=\{(x_{1,1},x_{1,2},\ldots,x_{N,1},x_{N,2})\in\Delta^{2N-1}:x_{1,1}+x_{1,2}=\nu_1,\ldots, x_{N,1}+x_{N,2}=\nu_N\}.\]  This will be useful in some examples when it comes to identifying possible limits.

In many cases the equations \eqref{edgeendlim} for the $\nu_i$ do not have a closed form solution, but there are some examples where they do; for example when $\mu_i=\frac{1}{N}$ for all $i$ and the matrix $A$ has suitable symmetries it can be seen that $\nu_i=\frac{1}{N}$ for all $i$.





\subsection{Proof of Theorem \ref{different}}

Let $z_1$ be the smallest linearly stable fixed point of the polynomial $R$, and $z_2>z_1$ be the largest. Linear stability ensures that 
$R'(z_1),R'(z_2)<1$. We may assume $\eps$ is sufficiently small that $R(z)$ has no other fixed points within $\eps$ of $z_1$ or $z_2$, and that $R'(z)<1-\kappa$
in this range for some $\kappa>0$.

Without loss of generality, we may assume that the diagonal elements of $A_{\theta}$ are all $1$, and we write the off-diagonal entries of $A_1$ as $\tilde{\alpha}_{i,j}$ so that the off-diagonal entries of $A_{\theta}$ are $\alpha_{i,j}=\theta \tilde{\alpha}_{i,j}$.  

We partition $S$ into two non-empty sets $S_1$ and $S_2$, and we will prove that with positive probability all communities whose labels are in $S_i$ have proportions of red converging to limits within $\eps$ of $z_i$.

Let $\hier[R]it$ (respectively, $\hier[B]it$) be the number of red (respectively, blue) edge-ends in community $i$ at time $t$.  For each $i\in S_1$, we will define an urn process with $\hier[R']it$ red balls and $\hier[B']it$ blue balls, which will give an upper bound on the proportion of red in community $i$. We initialise the urns at some time $t_0$ to be chosen later, such that $\hier[R']i{t_0}=\hier[R]i{t_0}$ and $\hier[B']i{t_0}=\hier[B]i{t_0}$. 

Fix $\delta_0>0$ to be smaller than $\min_i\nu_i$. We will show by induction that, provided 
\begin{equation}\abs{\hier[Y]it-\nu_i}<\delta_0,\text{ for all }i\text{ and for all }t\geq t_0,
	\label{close-to-nu}\end{equation}
we may couple the two processes such that $\hier[R']it+\hier[B']it\geq \hier[R]it+\hier[B]it$ and $\hier[B']it\leq \hier[B]it$ for each $t\geq t_0$. Write $r'=\frac{\hier[R']it}{\hier[R']it+\hier[B']it}$ and $r=\frac{\hier[R]it}{\hier[R]it+\hier[B]it}$; it follows that $r'\geq r$.
In the analysis that follows, we assume \eqref{close-to-nu} holds.

For $i\in S$, set \[q_{i,i}^{-}=\frac{\nu_i-\delta_0}{(\nu_i-\delta_0)+\sum_{k\in S\setminus\{i\}}\theta \tilde{\alpha}_{k,i}(\nu_k+\delta_0)},\] and for $i,j\in S$ with $i \neq j$ set 
\[q_{i,j}^{-}=\frac{\theta \tilde{\alpha}_{i,j}(\nu_i-\delta_0)}{\theta \tilde{\alpha}_{i,j}(\nu_i-\delta_0)+(\nu_j+\delta_0)+\sum_{k\in S\setminus\{i,j\}}\theta \tilde{\alpha}_{k,j}(\nu_j+\delta_0)},\]
so that $q_{i,j}^-$ is the minimum possible probability with which a new vertex in community $j$ forms an edge to community $i$. Define $q_{i,j}^+$ similarly to be the maximum. Note that, for all $i,j\in S$, $q_{i,j}^+-q_{i,j}^-\leq c\theta\delta_0$ for some constant $c$ which depends only on $A_1$ and $\mu$.

The method of adding balls to the urns at time $t+1$ depends on a random variable $C_{t+1}$ which is $j$ with probability $\mu_j$; this corresponds to the choice of community for the new vertex. For the urn in community $i$, choose coupled variables $X_1\leq X_2$ with $X_1\sim\bin{m,q_{i,C_{t+1}}^-}$ and $X_2\sim\bin{m,q_{i,C_{t+1}}^+}$. Note that $X_1,X_2$ do not depend on the current state of the urn. By choice of $q_{i,j}^-$ and $q_{i,j}^+$, we may couple these with the actual number of edges formed from the new vertex to community $i$, $X$, such that $X_1\leq X\leq X_2$.

If $C_{t+1} \neq i$, we add $X_2$ balls to the urn. The first $X_1$ of these are independently chosen to be red with probability $r'$, and the remaining $X_2-X_1$ are all red. In this case, since we add $X_2$ new balls to the urn and $X$ new edge-ends to community $i$, we have $\hier[R']i{t+1}+\hier[B']i{t+1}\geq \hier[R]i{t+1}+\hier[B]i{t+1}$ by the induction hypothesis. Also, since $\hier[B']i{t+1}-\hier[B']it\sim\bin{X_1,1-r'}$ and $\hier[B]i{t+1}-\hier[B]it\sim\bin{X,1-r}$, by the induction hypothesis we may couple these variables so that $\hier[B']i{t+1}\leq \hier[B]i{t+1}$.

If $C_{t+1}=i$, we add $X_2+m$ balls to the urn, of which the first $X_1$ balls are independently chosen to be red with probability $r'$, and the next $X_2-X_1$ are all red. Again, this ensures that $\hier[R']i{t+1}+\hier[B']i{t+1}\geq \hier[R]i{t+1}+\hier[B]i{t+1}$, and that we may couple such that the number of these balls that are blue does not exceed the number of new edges to existing blue vertices.

The final $m$ balls will be either all red or all blue. The colour will depend on the graph process, although the overall probability of these balls being red does not. We choose this probability as follows. Let $\tilde r=\sum_{j\in S}q'_jr'_j+(1-q')r'_2$, where $r'_i\in[r'-4c\theta\delta_0\mu_i^{-1},r']$, $r'_j\in[0,1]$ for $j\neq i$, and $q'_j\in[q_{j,i}^-,q_{j,i}^+]$ are chosen to maximise $R(\tilde r)$. Choose the balls to be red with probability $R(\tilde r)$. Provided $R(\tilde r)$ is at least the probability of the new vertex being red, we may couple this choice with the graph process such that these balls are red whenever the new vertex is.

Suppose that this is not the case. Note that the new vertex is red with probability $R(\sum_{j=1}^N q_jr_j)$, where for $j\neq i$ $r_j\in[0,1]$ is the proportion of red edge-ends in community $j$, $r_i=r$, and $q_j\in[q_{j,i}^-,q_{j,i}^+]$ is the actual probability of forming an edge to community $j$ given that the new vertex is in community $i$. So this is at most $R(\tilde r)$ unless we have $r<r'-4c\theta\delta_0\mu_i^{-1}$. Also, we may assume $\hier[B]it\leq \hier[B']it+m$, since otherwise we necessarily have $\hier[B]i{t+1}\geq \hier[B']i{t+1}$. Thus we have
\begin{align}
	\notag\frac{\hier[R']it+\hier[B']it}{\hier[R]it+\hier[B]it}\cdot\frac{\hier[B']it+m}{\hier[B']it}&\geq\frac{\hier[R']it+\hier[B']it}{\hier[R]it+\hier[B]it}\cdot\frac{\hier[B]it}{\hier[B']it}\\
	&\notag\geq 1+4c\theta\delta_0\mu_1^{-1}\cdot\frac{\hier[R']it+\hier[B']it}{\hier[B']it}\\
	&\geq1+4c\theta\delta_0\mu_1^{-1}.\label{too-many-extra}
\end{align}
However, at each step of the process the number of balls added to the urn exceeds the number of edge-ends added to community $i$ by $X_2-X$, which is at most $\bin{m,q_{i,j}^+-q_{i,j}^-}$ for some $j$, \ie at most $\bin{m,c\theta\delta_0}$, whereas with probability $\mu_i$ we add at least $m$ edge-ends. Thus if $t_0$ is sufficiently large, we have 
\begin{equation}\frac{\hier[R']it+\hier[B']it}{\hier[R]it+\hier[B]it}\leq 1+2c\delta_0\theta/\mu_1\text{ for all }t\geq t_0
	\label{few-extra-balls}\end{equation}
with probability at least $1-\zeta_0/2N$, where $\zeta_0$ is a constant to be chosen later. However, this contradicts \eqref{too-many-extra} provided $\hier[B']it$ is sufficiently large.

Now define a function $\tilde R^{(i)}(z)$ as follows. For each $z$, let $\tilde r=\sum_{j=1}^N r_jq_j$ where $r_i\in[z-4c\theta\delta_0/\mu_i,z]$, $r_j\in[0,1]$ for $i\neq j$, and $q_j\in [q_{i,j}^-,q_{i,j}^+]$ are chosen to maximise $R(\tilde r)$. Let $\tilde R^{(i)}(z)=R(\tilde r)+\mu_i(q_{i,i}^+-q_{i,i}^-)$. Now the urn process has positive probability of converging to any stable root of $\tilde R^{(i)}(z)-z=0$. Note that $R(z)\leq \tilde R^{(i)}(z)\leq R(z)+O(\theta)$, so for $\theta$ sufficiently small there is still at least one stable root in $(z_1,z_1+\eps)$, and we have positive probability of converging to it, meaning that the proportion of red in community $i$ is bounded above by $z_1+\eps$.

We now construct analogous lower bound urn processes for all communities with labels in $S_2$. Simultaneously, there is positive probability of these urns converging to something that exceeds $z_2-\eps$.

Thus we may choose $t_0$ sufficiently large and appropriate initial conditions such that, with probability at least $1-\zeta_0$, the upper bound urn for each community with label in $S_1$ remains below $z_1+\eps$ for all $t\geq t_0$, the lower bound urn for each community with label in $S_2$ remains above $z_2-\eps$ for all $t\geq t_0$, and the couplings continue to be valid, \ie we have \eqref{close-to-nu} and \eqref{few-extra-balls}, and the initial numbers of blue balls in urns from the first group and red balls in urns from the second group are sufficiently large.

Now we define a new lower bound process for a community $i$ with $i\in S_1$. This is done in the same way (with all discrepancies resolved in favour of blue, rather than red), except that we define $\tilde r$ to minimise $R(\tilde r)$ subject to $r'_i\in[r,r+\theta\delta_0]$, $r'_j\in[z_2-\eps,1]$ for $j\in S_2$, $r'_j\in[0,z_1+\eps]$ for $j\in S_1\setminus\{i\}$, and $q_j\in[q_{j,i}^-,q_{j,i}^+]$, \ie we update the range for $r'_j$ where $j\neq i$ to the window of possible values for the proportion of red edge-ends in community $j$. Since this ensures $\tilde r=r'+\Theta(\theta)$, for any $r<z_1-c'\theta$ we have $\tilde R(r)=R(\tilde r)\geq \tilde r=r+\Theta(\theta)$, ensuring this lower bound process cannot converge to any point below $z_1-c'\theta$; here $c'$ is some constant which depends only on the type assignment rule and the community structure. In particular, for sufficiently large $t$ we have the proportion of red in communities in $S_1$ is in the range $(z_1-c'\theta,z_1+\eps)$ and likewise the proportion of red in communities in $S_2$ is in $(z_2-\eps,z_2+c'\theta)$.


We now iterate this process. Suppose that for a community $j\in S_2$ the proportion of red in community $j$ is in the range $(a_j,a_j+b)\subset(z_2-\eps,z_2+c'\theta)$, while for a community $j\in S_1$ the proportion of red in community $j$ is in the range $(a_j,a_j+b)\subset(z_1-c'\theta,z_2+\eps)$ Choose some $\delta_1>0$ and assume \eqref{close-to-nu} holds with $\delta_1$ instead of $\delta_0$. Redefine $q_{i,j}^-,q_{i,j}^+$ with $\delta_1$ instead of $\delta_0$. Considering the urn for community $i$ with $i\in S_1$ again, for each $z$ let $\tilde r_U(z)$ be the value of $\tilde r=\sum_{j=1}^N q_j r_j$ which maximises $R(\tilde r)$
subject to $r_i\in[r'-4c\theta\delta_i/\mu_1,r'+4c\theta\delta_i/\mu_1]$, $r_j\in[a_j,a_j+b]$ for $j\neq i$ and $q_j\in[q_{j,i}^-,q_{j,i}^+]$, and let $\tilde r_{L}$ be the value that minimises $R(\tilde r)$. We use these functions to define upper and lower bound processes as before, where if the current proportion of red in the urn is $r'$, the $m$ balls corresponding to the addition of a new vertex are red with probability $R(\tilde r_U(r'))$ and $R(\tilde r_L(r'))$ respectively. The upper bound process converges to a root of $R(\tilde r_U(r'))+\mu_1(q_{i,i}^+-q_{i,i}^-)=r'$, and the lower bound process to a root of $R(\tilde r_L(r'))-\mu_1(q_{i,i}^+-q_{i,i}^-)=r'$, with probability at least $1-\zeta_1/2N$ where $\zeta_1$ is an appropriately-chosen constant. Let $z_U$ be the largest root of the first equation in $(z_1-c'\theta,z_1+\eps)$, and $z_L$ be the smallest root of the second equation in that range.

Now we have $R(\tilde r_U(z_U))=z_U-\mu_1(q_{i,i}^+-q_{i,i}^-)$ and $R(\tilde r_L(z_L))=z_L+\mu_1(q_{i,i}^+-q_{i,i}^-)$, giving
\[R(\tilde r_U(z_U))-R(\tilde r_L(z_L))=z_U-z_L-2\mu_1(q_{i,i}^+-q_{i,i}^-).\]
Also, 
\[\tilde r_U(z_U)-\tilde r_L(z_L)\leq z_U-z_L+\theta_1(1-q_{i,i}^-)b+8c\delta_1\theta_1/\mu_1.\]

We aim to show that, choosing $\delta_1$ appropriately, we have $z_U-z_L<\gamma b$ for some constant $\gamma$, whence we may iteratively obtain new upper and lower bounds which are a constant factor closer than the previous ones. Note that, provided $\delta_1$ is sufficiently small in terms of $b$, we either have $z_U-z_L\leq b/2$ or $R(\tilde r_U(z_U))>R(\tilde r_L(z_L))$. Assuming the latter, we obtain by the mean-value theorem that
\begin{align*}R'(z)&\geq\frac{z_U-z_L-2\mu_1(q_{i,i}^+-q_{i,i}^-)}{z_U-z_L+\theta_1(1-q_{i,i}^-)b+8c\delta_1\theta_1/\mu_1}\\
	&>1-\frac{\theta_1(1-q_{i,i}^-)b+8c\delta_1\theta_1/\mu_1+2\mu_1(q_{i,i}^+-q_{i,i}^-)}{z_U-z_L}\end{align*}
for some $z\in(z_L,z_U)$.

Since we have $R'(z)<1-\kappa$ in the required range, for some $\kappa>0$ which does not depend on $\theta$, we obtain, for $\delta_1$ sufficiently small, $\theta b>\kappa(z_U-z_L)$, and thus $z_U-z_L<\kappa^{-1}\theta b$. For $\theta$ sufficiently small, this gives an updated pair of bounds for community $i$ which are closer together than the existing bounds on the other communities by a constant factor.

Iterating this procedure therefore gives upper and lower bounds for community $i$ which converge to the same value, and this holds for every community with probability at least $1-\sum_{j\geq 0}\zeta_j>0$. The initial bounds obtained ensure that each limit is in the desired range (though different communities in $S_1$ may converge to different limits, and likewise for $S_2$).

\subsection{Proofs of Proposition \ref{touchpoint}, Theorem \ref{same}, Theorem \ref{determinant} and Theorem \ref{stable}}
We shall use the following result more than once.
\begin{lem}\label{lem:shift-up}Let $z_1<z_2$ be such that $R(z)>z_1$ for $z\in[z_1,z_2)$, and either $R(z_2)>z_1$ or $\alpha_{ii}>0$ for each $i$. Then there exists $\eps>0$ such that almost surely one of the following holds:
\begin{enumerate}[(i)]\item $\lim\inf\hier[Z]tj<z_1-\eps$ for some $i$;
\item $\lim\sup\hier[Z]ti>z_2+\eps$ for some $i$; or
\item $\lim\inf\hier[Z]ti>z_1+\eps$ for every $i$.
\end{enumerate}
\end{lem}
\begin{proof}Suppose that with positive probability (i) and (ii) do not occur, for some value of $\eps$ to be chosen later. We condition on this event and show that (iii) almost surely occurs. It is sufficient to show that for an arbitrary $i$ and suitable $\eps=\eps_i$ we obtain $\lim\inf\hier[Z]ti>z_1+\eps$, since then (iii) follows for $\eps=\min_i\eps_i$.

Recall that at time $t$ community $i$ gains at most $m$ edge-ends meeting existing vertices, and gains $m$ edge-ends meeting a new vertex with probability $\mu_i$. The former are each independently red with probability $\hier[Z]ti$, and the latter are red with probability $R(r_t)$, where 
$r_t=\frac{\sum_j\alpha_{ji}\hier[Y]tj\hier[Z]tj}{\sum_j\alpha_{ji}\hier[Y]tj}$.
In particular, since $r_t$ is a convex combination of $\hier[Z]tj$ we have $\min_j\hier[Z]tj\leq r_t\leq\max_j\hier[Z]tj$. Thus the expected number of edge-ends added to community $i$ at time $t$ is $e_t=m\mu_i+k_t$, for some $k_t\leq m$, and the expected number of red edge-ends amongst these is $f_t=m\mu_iR(r_t)+k_t\hier[Z]ti$. We will show that almost surely for all sufficiently large $t$ we have $f_t> (z_1+\eps)e_t$; since the number of edges added at each time is bounded, (iii) follows. 

Note that $f_t/e_t$ is monotonic in $k_t$, being increasing if $\hier[Z]ti>R(r_t)$ and decreasing otherwise. Thus, since $0\leq k_t\leq m$, we have \begin{equation}\label{f-e-bounds}f_t/e_t\geq\min\left\{ R(r_t),\frac{\mu_iR(r_t)+\hier[Z]ti}{\mu_i+1}\right\}.\end{equation}
Suppose $R(z_2)>z_1$. Then by continuity of $R$, there is some $\eps>0$ such that $R(z)>z_1+3\mu_i^{-1}\eps$ for $z\in=[z_1-\eps/2,z_2+\eps/2]$. For all sufficiently large $t$ we have $\min_j\hier[Z]tj>z_1-\eps/2$ and $\max_j\hier[Z]tj<z_2+\eps/2$, so $R(r_t)\geq z_1+3\mu_i^{-1}\eps$. Thus the bound in \eqref{f-e-bounds} is at least $\frac{\mu_i(z_1+3\mu_i^{-1}\eps)+z_1-\eps/2}{\mu_i+1}=z_1+\frac{5\eps}{2\mu_i+2}>z_1+\eps$, as required.

Now we deal with the case $R(z_2)=z_1$, where we have $\alpha_{ii}>0$. Recall that $\hier[Y]ti\to\nu_i$ almost surely, and so for sufficiently large $t$ we have $\hier[Y]ti>\nu_i/2$. Set $x=\frac{\alpha_{ii}\nu_i}{2\max_j\alpha_{ji}}$. It follows that, for $t$ sufficiently large, we have 
\begin{equation}\label{r-bound}r_t<x\hier[Z]ti+(1-x)\max_j\hier[Z]tj\end{equation}
and $k_t\geq\mu_ixm$. The latter implies
\begin{equation}\label{f-e-bounds2}f_t/e_t\geq\min\left\{\frac{R(r_t)+x\hier[Z]ti}{1+x},\frac{\mu_iR(r_t)+\hier[Z]ti}{\mu_i+1}\right\}.\end{equation}
Let $z_3=z_1x/2+z_2(1-x/2)$; since $z_1<z_3<z_2$ we may find $\eta>0$ such that $R(z)>3\mu_i^{-1}\eta$ for $z\in[z_1-\eta/2,z_3+\eta/2]$. Choose $\zeta>0$ such that $\frac{x(z_2-z_1)/2-\zeta}{x+1}>\zeta$, and choose $\xi>0$ such that $R(z)>z_1-\zeta$ for $z\in[z_2,z_2+\xi/2]$. Finally, set $\eps=\min\{\eta,\zeta,\xi\}$.

For all sufficiently large $t$ we have $\min_j\hier[Z]tj>z_1-\eps/2$ and $\max_j\hier[Z]tj>z_2+\eps/2$. Provided $\hier[Z]ti<(z_1+z_2)/2$, \eqref{r-bound} gives $r_t<z_3+\eta/2$ and hence $R(r_t)\geq z_1+3\mu_i^{-1}\eta$, and as before it follows that $f_t/e_t>z_1+\eta$. If $\hier[Z]ti<(z_1+z_2)/2$ then \eqref{f-e-bounds2} gives $f_t/e_t> \frac{z_1-\zeta+x(z_1+z_2)/2}{1+x}>z_1+\zeta$. Since $\eps\leq\eta,\zeta$ this completes the proof.
\end{proof}


A technical difficulty in some cases is to rule out the possibility of unstable fixed points at $0$ and/or $1$ becoming accumulation points. We give a general result on non-convergence to $0$.
\begin{lem}\label{lem:nozero}Suppose that either of the following conditions holds:
\begin{enumerate}[(a)]
\item\label{nozero} $R(0)>0$, and either $R(R(0))>0$ or $\alpha_{ii}>0$ for each $i$;
\item\label{unstable} $R$ has a linearly unstable zero at $0$.
\end{enumerate}
Then there exists some $\eta>0$ such that for each $i$ we have $\lim\inf_{t\to\infty}\hier[Z]ti\geq\eta$ almost surely.
\end{lem}
\begin{rem}The additional condition on the matrix in \eqref{nozero} is necessary to exclude situations such as in Theorem \ref{same}, part 2, where it is possible for some communities to converge to $0$ and others to $1$ despite neither being a fixed point of $R$.
\end{rem}
\begin{proof}
Note that, since $R(z)\not\equiv 0$, we have $R(z)>0$ for $z\in (0,1)$. If \eqref{nozero} holds then taking $(z_1,z_2)=(0,1)$ in Lemma \ref{lem:shift-up} immediately gives the desired conclusion.

Now assume \eqref{unstable} holds. If $R(1)=0$ then, by \eqref{nozero} applied after swapping colours, almost surely there exists some $\eta'>0$ such that $\hier[Z]ti\leq 1-\eta'$ for all $i$ and all $t$ sufficiently large. If $R(1)>0$ then we may instead take $\eta'=0$. In either case, since $0$ is a linearly unstable root and $R(1-\eta')>0$, there is some $\lambda>0$ and $\delta_0>0$ such that $R(z)>\min\{(1+\lambda)z,\delta_0\}$ whenever $0<z\leq 1-\eta'$. 

Write $c=\min_{i\in [N]}\mu_i/2$ and $\kappa=\min_i\nu_i/2$. Set $\lambda'=\lambda/(2+c+\lambda c)<1/c$. Choose $\eta=\delta_0\frac{1-c\lambda'}{1+2\lambda'}$.

For each $t$, set $W_t=\min_{i\in[N]}\hier[Z]it$. We choose a sequence of values $\delta_1,\delta_2,\ldots$, as follows. Choose $t_0$ sufficiently large that, for all $t\geq t_0$, we have $\hier[Z]ti\leq 1-\eta'$ and $\hier[Y]it\geq\kappa$ for all $i$. Let $t_1\geq t_0$ be the next time satisfying $W_{t_1}<\frac{\delta_0}{1+2\lambda'}$, if it exists, and set $\delta_1=W_{t_1}$. Now, for each $i\geq 2$, let $t'_{i}$ be the next time after $t_{i-1}$ that either $W_{t'_i}\leq\delta_{i-1}(1-c\lambda')$ or $W_{t'_i}\geq\delta_{i-1}(1+c\lambda'/2)$ (if it exists; we shall subsequently argue that one of these events occurs almost surely). Choose $t_i\geq t'_i$ to be the next time with $W_{t_i}<\frac{\delta_0}{1+2\lambda'}$, if it exists, and set $\delta_{i}=W_{t_i}$.

Suppose $t_{i-1}$ exists for some $i\geq 2$. Note that we have $(1+2\lambda')\delta_{i-1}<\delta_0$, and hence $R(z)\geq(1+2\lambda')\delta_{i-1}$ for all $z\in[(1-c\lambda')\delta_{i-1},1-\eta']$. Thus, while we have $W_t\geq\delta_{i-1}(1-c\lambda')$, each additional edge-end in community $j$ created at a new vertex has probability at least $\delta_{i-1}(1+2\lambda')$ of being red, and each additional edge-end created at an existing vertex has probability at least $\delta_{i-1}(1-c\lambda')$ of being red, so the expected proportion of red edge-ends created in community $j$ is at least $\delta_{i-1}(1+c\lambda')$. Consequently, almost surely eventually either $W_t<\delta_{i-1}(1-c\lambda')$ or $W_t\delta_{i-1}(1+c\lambda')$, \ie $t'_{i}$ exists. If $t'_{i}$ exists but $t_{i}$ does not, then $W_t\geq\frac{\delta_0}{1+2\lambda'}>\eta$ for all $t\geq t'_{i}$. Thus we may assume $t_i$ exists for every $i$.

We say that there is a ``decrease'' at $i$ if $\delta_i\leq\delta_{i-1}(1-c\lambda')$. If there is no decrease at $i$ then we have $\delta_i\geq\min\{\delta_{i-1}(1+c\lambda'/2),\frac{\delta_0}{1+2\lambda'}-o(1)\}$, and in particular if there are only finitely many decreases we have $\lim\inf_{i\to\infty}\delta_i\geq\frac{\delta_0}{1+2\lambda'}$, and consequently $\lim\inf_{t\to\infty}W_t\geq\eta$. We will show that in fact this almost surely happens, giving a contradiction.

We bound the probability of a decrease, \ie that any community reaches $\delta_{i-1}(1-c\lambda')$ before all communities are at least $\delta_{i-1}(1+c\lambda'/2)$, using Hoeffding's inequality. We take a union bound over the following events:
\begin{enumerate}[(i)]
\item for some $t$ with $t_{i-1}<t<3t_{i-1}$, and some $j$, community $j$ is below $\delta_{i-1}(1-c\lambda')$ at time $t$, and $t$ is minimal for this property;
\item none of the above events occur, but for some $j$ community $j$ is below $\delta_{i-1}(1+c\lambda'/2)$ at time $3t_{i-1}$. 
\end{enumerate}
Since there are at least $2mt_{i-1}\kappa$ edge-ends in community $j$ at time $t_{i-1}$, at most $2m(t-t_{i-1})$ edge-ends are added between times $t_{i-1}$ and $t$, and at least a $\delta_{i-1}$ proportion of the former are red, in order for (i) to occur we must have
\[\frac{t_1\kappa\delta_{i-1}}{t_{i-1}\kappa+t-t_{i-1}}\leq\delta_{i-1}(1-c\lambda'),\]
\ie $t-t_{i-1}\geq \rho t_{i-1}$, where $\rho=c\lambda'\kappa/(1-c\lambda')>0$ does not depend on $t_{i-1}$ or $\delta_{i-1}$.

Fix a community $j$ and reveal for each time step between $t_{i-1}$ and $3t_{i-1}$ the numbers of edge-ends added to community $j$ at old and new vertices. The probability that, for some $t$ with $(1+\rho) t_{i-1} <t\leq 3t_{i-1}$, we have had fewer than $0.9\mu_j(t-t_{i-1})$ new vertices added to community $j$ between times $t_{i-1}$ and $t$ is exponentially small in $t_{i-1}$. Assuming this does not occur, and assuming no bad event of type (i) occurs in any community before time $t$, each of these new vertices is red with probability at least $\delta_{i-1}(1+2\lambda')$, and the (at most) $m(t-t_{i-1})$ other edge-ends created in community $j$ are red with probability at least $\delta_{i-1}(1-c\lambda')$, and so we can couple these to binomial distributions of the appropriate probability. For an event of either type to occur, the actual proportion of red edge-ends added between times $t_{i-1}$ and $t$ (or $t_{i-1}$ and $3t_{i-1}$) must be at most $\delta_{i-1}(1+c\lambda'/2)$, requiring one of the two binomial variables to differ from its expectation by a constant multiplicative factor. By a standard Chernoff bound, this has probability which decays exponentially in the expectation, \ie exponentially in $\delta_{i-1}t_{i-1}$. 

Note that, since $t_i\delta_i$ is (up to a constant) the number of red edge-ends in some community, since the number of red edge-ends in each community increases at least logarithmically over time almost surely, and since we must have $t_i\geq t_{i-1}(1+\Theta(1))$ in order for the proportion of red edge-ends in some community to change by a factor of $1-c\lambda'$ or $1+c\lambda'/2$, these probabilities are almost surely summable, and hence by Borel--Cantelli almost surely there are only finitely many decreases, as required.
\end{proof}

\subsubsection{Proof of Proposition \ref{touchpoint}}
Note that we have $P(z)\geq z$ for all $z\leq z^*$, and $P(z)\leq z$ for all $z\geq z^*$. Write $\delta=\min_i\nu_i/2$.

Suppose that with positive probability all communities converge to limits, but that not all limits are equal. Let the random variables $Z_1$ and $Z_2$ be the largest and smallest limits, and let $z_1<z_2$ be values chosen so that, for any $\eps>0$, with positive probability we have $\abs{Z_i-z_i}<\eps/2$ for $i=1,2$. We condition on this event, where $\eps$ is to be chosen later. We may assume without loss of generality that $\frac{z_1+z_2}{2}\leq z^*$, and that community $1$ converges to $Z_1$ but community $2$ converges to $Z_2$. For $t$ sufficiently large each community is within $\eps/2$ of its eventual limit, and the relative size of each community is within $\delta$ of its limit $\nu_i$, for any given $\delta>0$. Note that there exists some $\theta^*>0$, which depends only on the community structure, such that for $\theta<\theta^*$ the probability of a new vertex in any community selecting a neighbour from its own community is at least $2/3$. Furthermore, since each entry of $A_1$ is positive, for each $\theta>0$ there is some $\eta=\eta(\theta)>0$ such that the probability of a new vertex in any community $i$ selecting a neighbour in community $j$ is at least $\eta$ for each pair $i\neq j$.

Consider the probability that a new vertex joining community $1$ becomes red. This is $R(r)$, where $r$ is the probability that the first edge formed by the new vertex is to a red vertex. If $\theta<\theta^*$ and $\eps$ is sufficiently small (in terms of $z_1$, $z_2$ and $\eta$), and $t$ is sufficiently large, then we have $r\leq 2(z_1+\eps)/3+(z_2+\eps)/3\leq z^*$, but also $r\geq (1-\eta)(z_1-\eps)+\eta(z_2-\eps)\geq z_1+2\eps$. Thus $R(r)\geq r\ge z_1+2\eps$, and so almost surely the proportion of red edge-ends in community $1$ will eventually reach $z_1+2\eps$, contradicting our assumptions.

\subsubsection{Proof of Theorem \ref{same}, part 1, and Theorem \ref{stable}}
First we will express the condition on the fixed points of $R(R(z))$ in Theorem \ref{same}, part 1, into an equivalent, but more convenient form.
\begin{lem}\label{rcond}Suppose that $R(z)$ has a unique stable fixed point $z^*$ in $[0,1]$, and no other fixed points in $(0,1)$.
Then the following are equivalent:
\begin{enumerate}[(i)]\item\label{root-condition} The only fixed points of $R(R(z))$ in $[0,1]$ are the fixed points of $R(z)$;
\item\label{two-point-condition}there do not exist $0\leq z'<z^*<z''\leq 1$ such that $R(z')\geq z''$ and $R(z'')\leq z'$.
\end{enumerate}
\end{lem}
\begin{proof}First we show the forward implication. Suppose \eqref{two-point-condition} is not true; note that this implies $z^*\in(0,1)$. The set of pairs $(z',z'')$ with $0\leq z'\leq z^*\leq z''\leq 1$ satisfying $R(z')\geq z''$ and $R(z'')\leq z'$ is closed, so there is a pair that maximises $z''-z'$. By assumption, this pair must have $z''-z'>0$, and it follows that $z'<z^*<z''$. We must have either $R(z')=z''$ or $R(z'')=z'$, since otherwise for sufficiently small $\eps>0$ the values $z'-\eps,z''+\eps$ would also violate \eqref{two-point-condition}. Suppose, without loss of generality, that $R(z')=z''$. Then $R(R(z'))=R(z'')\leq z'$. Since $0$ is not a stable root, we have $R(R(\eps))>\eps$ for all sufficiently small $\eps>0$. Consequently there is a fixed point of $R(R(z))$ in $(0,z']$, but this interval does not include $z^*$, and so \eqref{root-condition} is not true.
	
Conversely, suppose that \eqref{root-condition} is not true, and let $z'$ satisfy $R(R(z'))=z'$ but $R(z')\neq z'$. Set $z''=R(z')$; since also $R(R(z''))=z''$ and $z'=R(z'')$, we may assume without loss of generality that $z'< z''$. Thus $R(z')>z'$ and $R(z'')<z''$, and so there is a fixed point of $R$ in the interval $(z',z'')$. Since the only fixed point in $(0,1)$ is $z^*$, we must have $z'<z^*<z''$, and so \eqref{two-point-condition} fails.
\end{proof}

\begin{proof}[Proof of Theorem \ref{same}, part 1]We have \eqref{two-point-condition} of Lemma \ref{rcond}. We also straightforwardly have $R(z)>z$ for $0<z<z^*$ and $R(z)<z$ for $z^*<z<1$. Write $c=\min_{i\in [N]}\mu_i/2$, and set
\begin{align*}Z_1&=\min_{i\in [N]}\liminf_{t\to\infty}\hier[Z]ti;\\
Z_2&=\max_{i\in [N]}\limsup_{t\to\infty}\hier[Z]ti.
\end{align*}
Suppose for a contradiction that with positive probability these are not both equal to $z^*$, and choose values $(z_1,z_2)\neq(z^*,z^*)$ such that for any $\eps>0$ there is positive probability that $|Z_1-z_1|,|Z_2-z_2|<\eps$. Either these are on the same side of $z^*$, \ie without loss of generality we have $z_1<z^*$ and $z_2\leq z^*$, or they are on opposite sides, \ie $z_1<z^*<z_2$. In the former case, clearly we have $R(z)\geq z>z_1$ for $z_1< z\leq z^*$, and so for all $z\in(z_1,z_2]$. In the latter case, we cannot have both a value $z_3\in[z_1,z^*)$ with $R(z_3)\geq z_2$ and a value $z_4\in(z^*,z_2]$ with $R(z_4)\leq z_1$, since this would imply $R(z_3)\geq z_2\geq z_4$ and $R(z_4)\leq z_1\leq z_3$, contradicting \eqref{two-point-condition} of Lemma \ref{rcond}. Consequently, at least one of these does not exist; assume without loss of generality we have $R(z)>z_1$ for all $z\in(z^*,z_2]$. Then we again have $R(z)>z_1$ for all $z\in(z_1,z_2]$. We also have $R(z_1)>z_1$, since this holds unless both $z_1=0$ and $0$ is an unstable fixed point, which is impossible by Lemma \ref{lem:nozero}. Now Lemma \ref{lem:shift-up} applies, contradicting the assumed properties of $(z_1,z_2)$.
\end{proof}

\begin{proof}[Proof of Theorem \ref{stable}]Let $(z_1,z_2)$, with $z_1<z^{*}<z_2$, be an interval strictly contained in the neighbourhood of $z^{*}$ for which $R$ is increasing.  Then, setting $c=\min_{i\in[N]}\mu_i/2$, there exists $\eps>0$ such that if $\hier[Z]ti\in (z_1-c\eps,z_2+c\eps)$ for all $i$  the probability of a new edge end in community $i$ created at a new vertex being red is at least $z_1+2\eps$, and the probability of a new edge end in community $i$ at an existing vertex being red is at least $z_1-c\eps$, with an analogous argument showing that these are at most $z_2-2\eps$ and $z_2+c\eps$ respectively.  By choice of $c$ it follows that, for sufficiently large $t$, conditional on $\hier[Z]ti\in (z_1,z_2)$ for all $i$ there will be positive probability that $\hier[Z]ni\in (z_1-c\eps,z_2+c\eps)$ for all $i$ and for all $n\geq t$, and on this event $\hier[Z]ni \to z^{*}$ almost surely.  To complete the proof, we observe that for sufficiently large $t$ there will always be a choice of the initial steps up to time $t$ which has positive probability and gives $\hier[Z]ti\in (z_1,z_2)$ for all $i$.
\end{proof}

\subsubsection{Proof of Theorem \ref{determinant}, part 1}
Define the parameters $Z_i^-=\lim\inf_{t\to\infty}\hier[Z]ti$ and $Z_i^+=\lim\sup_{t\to\infty}\hier[Z]ti$, for $i=1,2$. Suppose for a contradiction that with positive probability these are not all equal to $z^*$, and let $z_1^-,z_1^+,z_2^-,z_2^+$ be specific values such that for any $\eps>0$ there is positive probability that each limit is within $\eps$ of the associated value. We will need to consider several cases separately.

First, suppose that all four values are the same side of $z^*$; without loss of generality, say they are all at most $z^*$. Then taking $z_1,z_2$ to be the largest and smallest values, Lemma \ref{lem:nozero} gives $z_1>0$. Since $R(z)>z$ for all $z\in(0,z^*)$, Lemma \ref{lem:shift-up} gives a contradiction.

Secondly, suppose that there are limits above and below $z^*$, and the highest and lowest are from different communities, \ie we have, without loss of generality, $z_1^-\leq z_2^-$ and $z_1^+\leq z_2^+$ with $z_1^-<z^*<z_2^+$. Since clearly in this case $0<z^*<1$, we have $0<z_1^-<z^*<z_2^+<1$ by Lemma \ref{lem:nozero} (noting that non-negative determinant implies diagonal entries are positive).

For $i=1,2$, let\[
f_i(x;a,b)=\frac{\alpha_{1,i}xa+\alpha_{2,i}(1-x)b}{\alpha_{1,i}x+\alpha_{2,i}(1-x)},\]
so that $f_i(\hier[Y]t1;\hier[Z]t1,\hier[Z]t2)$ gives the probabilities of a neighbour of a new vertex added at time $t+1$ being red conditional on the new vertex being in community $i$. Note that $(f_1(x;a,b),f_2(x;a,b))$ is the outcome of multiplying $(a,b)$ by a matrix $\boldsymbol B_x$ obtained from $\boldsymbol A$ by multiplying first each row, and then each column, by positive constants. Since these operations preserve the sign of the determinant, it follows that $f_1(x;a,b)\leq f_2(x;a,b)$ whenever $a\leq b$. 

Recall that $\hier[Y]t1\to\nu_1$ almost surely, where $\nu_1\in(0,1)$. Now we have \[f_1(\nu_1;z_1^-,z_2^+)\leq f_2(\nu_1;z_1^-,z_2^+),\] and in particular either $f_1(\nu_1;z_1^-,z_2^+)\leq z^*$ or $f_2(\nu_1;z_1^-,z_2^+)\geq z^*$ (or both). Assume without loss of generality that $f_1(\nu_1;z_1^-,z_2^+)\leq z^*$. There is some $\eps>0$ such that $R(z)\geq z_1+\eps$ for $z\in[z_1^--\eps,z^*+\eps]$. We may choose $\delta>0$ such that $\abs{x-\nu_1}<\delta$ implies $\|B_{x}-B_{\nu_1}\|_\infty<\eps/4$, and consequently $\abs{f_1(x;a,b)-f_1(\nu_1;a,b)}\leq\eps/2$ for any $a,b$.

Suppose that $\hier[Z]t1\leq z_1+\eps/2$, $\hier[Z]t2\leq z_2+\eps/2$ and $\abs{\hier[Y]t1-\nu_1}<\delta$. Set $\hier[W]ti=f_i(\hier[Y]t1;\hier[Z]t1,\hier[Z]t2)$, so that the probability of a new vertex added to community $i$ at time $t$ being red is given by $R(\hier[W]ti)$. 

Suppose that $\hier[Z]t1\leq z_1^-+\eps/2$. Provided $t$ is sufficiently large that $\hier[Z]ti\in(z_1^--\eps/2,z_2^++\eps/2)$ for each $i$ and $|\hier[Y]t1-\nu_1|<\delta$, we have $\hier[W]t1\leq y'_1+\eps/2\leq z^*+\eps$, and also $\hier[W]t1\geq z_1^--\eps/2$, so consequently $R(\hier[W]t1)\geq z_1+\eps$. 

It follows that, for $t$ sufficiently large, while $\hier[Z]t1$ remains below $z_1^-+\eps/2$ the expected proportion of red edge-ends among new edge-ends meeting new vertices in community $1$ is at least $z_1^-+\eps$, and so the expected proportion of red edge-ends among new edge-ends in community $1$ is at least $\hier[Z]t1+\mu_1\eps/2$. Consequently, $\hier[Z]t1$ almost surely reaches $z_1+\eps/2$ from any point below it, but fails to reach $z_1+\eps/4$ from $z_1+\eps/2$ with positive probability. Therefore $\liminf_{t\to\infty}\hier[Z]t1\geq z_1+\eps/4$, a contradiction.


The third and final case is that the two extreme values are on opposite sides of $z^*$, but correspond to the same community, \ie without loss of generality we have $z_1^-<z_2^-$ and $z_2^+<z_1^+$ with $0<z_1^-<z^*<z_1^+<1$ (where again Lemma \ref{lem:nozero} excludes the possibility of $0$ or $1$). Now we have
\[f_1(\nu_1;z_1^-,z_2^+)\leq f_2(\nu_1;z_1^-,z_2^+).\]
If $f_1(\nu_1;z_1^-,z_2^+)\leq z^*$, the analysis above goes through, so we must have 
\[z^*<f_1(\nu_1;z_1^-,z_2^+)\leq f_2(\nu_1;z_1^-,z_2^+)<z_2^+.\]
Similarly, we must have 
\[z_2^-<f_2(\nu_1;z_1^+,z_2^-)\leq f_1(\nu_1;z_1^+,z_2^-)<z^*.\]
In particular, it follows that $z_2^-<z^*<z_2^+$.

Write $y_1=f_1(\nu_1;z_1^-,z_2^+)$ and consider the minimum value of $R(z)$ for $z\in[z^*,y_1]$. If this is greater than $z_1^-$ then we have some $\eps>0$ such that provided $\hier[Z]t1\in (z_1^--\eps/2,z_1^-+\eps/2)$ and $\hier[Z]t2<z_2^++\eps/2$ and $|\hier[Y]t1-\nu_1|<\delta$, we have $\hier[W]t1\leq y_1+\eps$ and hence $R(\hier[W]t1)>z_1^-+\eps$, giving a contradiction as before.

Thus we must have some value $y\in(z^*,y_1)$ with $R(y)<z_2^-$. Choose some $y'\in(y,z_2^+)$ such that $f_2(\nu_1;z_1^-,y')>z^*$; this exists since $f_2(z_1^-,z_2^+)>z^*$. Take $\eta>0$ sufficiently small that $z^*,y,y',z_2^+$ are all at least $\eta$ apart, that $R(z)<z_2^--\eta$ for all $z\in[y-\eta,y+\eta]$, that $R(z)<y'-\eta$ for all $y'<z<y'+\eta$, and that $f_2(\nu_1;z^*,y+\eta)<y-\eta$.

Note that for any $\delta>0$ we have $\hier[Z]t2\geq z_1^--\delta$ and $\abs{\hier[Y]t1-\nu_1}<\delta$ for sufficiently large $t$, and $\hier[Z]t2\geq z_2^+-\delta$ infinitely often, and so choosing $\delta$ suitably we have $\hier[W]t2>y'+\eta$ infinitely often by choice of $y_1$. Similarly, since $f_2(\nu_1;z_1^+,z_2^-)<z^*$ we have $\hier[Z]t2,\hier[W]t2<y-\eta$ infinitely often. However, we will argue that the probability of reaching the region $\hier[z]2t>y'+\eta$ before returning to the region $\hier[Z]2t,\hier[W]2t<y-\eta$ is exponentially small, and thus almost surely this happens only finitely often, giving a contradiction.

Suppose $\hier[Z]2{t_0},\hier[W]2{t_0}<y-\eta$, and consider $t\geq t_0$. We first argue that with suitably high probability we have $\hier[Z]1t<y$ before either $\hier[Z]2t>y$ or $\hier[W]2t>y$; by assumption one of these things eventually happens. Indeed, while $\hier[Z]1t>y$ and $\hier[W]2t<y$ we cannot have $\hier[Z]2t>y$ (since $\hier[W]2t$ is a convex combination of the other two). However, if $\hier[Z]1t>y$ and $\hier[Z]2t<y$ and $\hier[W]2t\in(y-\eta,y)$ then we have $\hier[Z]1t\geq\hier[W]t1\geq \hier[W]2t>y-\eta$, and hence $R(\hier[W]2t)<z_2^--\zeta<\hier[Z]2t$ and $R(\hier[W]1)<\hier[Z]t1$. Thus both $\hier[Z]1t$ and $\hier[Z]2t$ are supermartingales, but in order for $\hier[W]2t$ to reach $y$ from $y-\eta/2$ before returning below $y-\eta$, one of them must increase by at least a constant, which is exponentially unlikely.

Now suppose $\hier[Z]1{t_1},\hier[Z]2{t_1},\hier[W]2{t_1}<y$. We next argue that we have at least one of $\hier[Z]1t<z^*$ or $\hier[Z]2t<z^*$ before either $\hier[Z]1t>y+\eta$ or $\hier[Z]2t>y+\eta$. Indeed, suppose $\hier[Z]1t,\hier[Z]2t\in[z^*,y+\eta]$. Then the same bounds apply to $\hier[W]1t,\hier[W]2t$, and so $R(\hier[W]1t),R(\hier[W]2t)\leq y-\eta$. Consequently the probability of either community reaching $y+\eta$ before one reaches $z^*$ is exponentially small.

If $\hier[Z]2t<z^*$ and $\hier[Z]1t<y+\eta$ then by choice of $\eta$ we have $\hier[Z]2t,\hier[W]2t<y-\eta$, as required. So we may assume $\hier[Z]1{t_2}<z^*$ and $\hier[Z]2{t_2}<y+\eta$. Now we argue that with suitably high probability we have $\hier[Z]2t,\hier[W]2t<z^*$ before $\hier[Z]2t>y'+\eta$. First note that if $\hier[Z]2t\in(y',y'+\eta/2)$ and $\hier[Z]1t<\max\{\hier[Z]2t,y'\}$ we have $z^*<\hier[W]2t<y'+\eta/2$ and thus $R(\hier[W]t2)<y'$, so with high probability we have $\hier[Z]1t>y'$ before $\hier[Z]2t>y'+\eta$. However, if $z^*<\hier[W]t1<y'+\eta$ then we have $R(\hier[W]t1)<y'$, and so it is exponentially unlikely for $\hier[Z]t2$ to reach $y'+\eta$ unless either $\hier[Z]t2$ exceeds $y'+\eta$ (which we know does not happen first) or $\hier[W]t1<z^*$ while $\hier[Z]t1>z^*$. However, these latter conditions imply $\hier[Z]2t,\hier[W]2t<z^*$, as required.


\subsubsection{Proof of Theorem \ref{same}, part 2}\label{period2point}

Let $\tilde{z}\neq z^*$ be a linearly stable fixed point of the second iterate of $R$, that is such that $R^2(\tilde{z})=R(R(\tilde{z}))=\tilde{z}$ and that $(R^2)'(\tilde{z})<1$. We will show that there is positive probability that $\hier[Z]t1\to \tilde{z}$ and $\hier[Z]t2\to R(\tilde{z})$; since $\tilde z\neq z^*$ these are not equal.


We start by calculating the form of the vector field $F$ for this community structure.  Defining, for $i=1,2$ and $j=1,2$, $Z_{i,j}(z)=\frac{x_{i,j}}{x_{i,1}+x_{i,2}}$, for $j=1,2$ we have \[Q_{1,j}(x)=\frac{x_{2,j}}{x_{2,1}+x_{2,2}}=Z_{2,j}(x),\] and similarly $Q_{2,j}(x)=Z_{1,j}(x)$.  Hence $G_{i,1}(x)=m\mu_i R(Z_{3-i,1}(x))$ and, similarly $G_{i,2}(x)=m\mu_i (1-R(Z_{3-i,2}(x)))$.

We also have, for $i,j=1,2$, \[H_{i,j}(x)=m\mu_{3-i} \frac{x_{i,j}}{x_{i,1}+x_{i,2}}=m\mu_{3-i} Z_{i,j}(x),\] and so we have \[F_{i,1}(x)=m \left(\mu_i R(Z_{3-i,1}(x))+\mu_{3-i} Z_{i,1}(x)\right)-2mx_{i,1}\] and \[F_{i,2}(x)=m\left(\mu_i(1-R(Z_{3-i,1}(x)))+\mu_{3-i}Z_{i,2}(x)\right)-2mx_{i,2}.\]

Let $x=\frac12(\tilde{z},1-\tilde{z},R(\tilde{z}),1-R(\tilde{z}))$.  Then $Z_{1,1}(x)=\tilde{z}$ and $Z_{2,1}(x)=R(\tilde{z})$, and we can check that $F_{1,1}(z)=m(\mu_i R^2(\tilde{z})+\mu_{3-i}\tilde{z}-2\tilde{z})=0$ by our assumption on $\tilde{z}$ and because $\mu_i+\mu_{3-i}=1$, and similarly for the other components of $F$.

For this community structure we can see that the equations \eqref{edgeendlim} giving the measure $\nu$ reduce to $\nu_1=\nu_2=\frac12$, whatever the values of $\mu_1$ and $\mu_2$.  Hence both $X^{(n)}_{1,1}+X^{(n)}_{1,2}$ and $X^{(n)}_{2,1}+X^{(n)}_{2,2}$ converge almost surely to $\frac12$ regardless of the types in the two communities, and so we may consider the dynamics of $F$ restricted to the set $\{x\in\Delta^3: x_{1,1}+x_{1,2}=x_{2,1}+x_{2,2}=\frac12\}$.  On this set we have $Z_{i,j}(x)=2x_{i,j}$ and so $\frac{\partial F_{i,1}}{\partial x_{i,1}}=-2\mu_1m$ and $\frac{\partial F_{i,1}}{\partial x_{3-i,1}}=2\mu_i mR'(2x_{2,1})$.  Hence for the choice of $x$ above the Jacobian is \[m\begin{pmatrix}-2\mu_1 & 2\mu_1 R'(R(\tilde{z})) \\ 2\mu_2 R'(\tilde{z}) & -2\mu_2 \end{pmatrix},\] which has both eigenvalues negative if and only if $(R^2)'(\tilde{z})=R'(\tilde{z})R'(R(\tilde{z}))<1$.

Hence if $(R^2)'(\tilde{z})<1$ then $x$ is a linearly stable fixed point of $F$.

The conclusion follows by applying Theorem 2.16 of Pemantle \cite{pemantlesurvey}, observing that there will always be a sequence of community and type for each vertex which has positive probability and gets arbitrarily close to $x$.

\subsubsection{Proof of Theorem \ref{determinant}, part 2}

Now suppose we have a matrix for which $\det(A)<0$. In particular this implies $B_{\boldsymbol \nu}\binom10$ has second coordinate larger. We can choose $\eps>0$ and $z_1<z_2$ such that given $\mathbf{x}$ is within $\eps$ of $\binom10$ and $\boldsymbol{\nu}'$ is within $\eps$ of $\boldsymbol{\nu}$ then $\mathbf{y}:=B_{\boldsymbol\nu'}\mathbf x$ satisfies $y_1<z_1<z_2<y_2$. We can choose $r,m$ such that $z_1<r/m<z_2$ and $\prob{\bin{m,z_1}>r},\prob{\bin{m,z_2}\leq r}<\eps$. We then use a modified minority rule: $p_k=1$ if $k\leq r$ and $p_k=0$ otherwise. Note that, since $p_k$ is decreasing, so is $R(z)$, meaning that $P'(z)\leq-1$, and so necessarily $P$ has a single root which is linearly stable.

By choice of parameters, provided $\hier[Z]t1\geq 1-\eps$, $\hier[Z]t2<\eps$, and $|\hier[Y]t1-\nu_1|<\eps$ then this trend in $\hier[Z]ti$ is preserved and with positive probability stays true forever, so they don't converge to the same value. 


\subsection{Proof of Proposition \ref{threecycle}}

Recall that here we have $S=\{1,2,3\}$ and \[A=\begin{pmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 1 & 0 & 0\end{pmatrix}.\] The calculation of the vector field $F$ for this community structure is similar to that in Section \ref{period2point}.  We have, for $j=1,2$, \[Q_{1,j} = \frac{x_{3,j}}{x_{3,1}+x_{3,2}} = Z_{3,j}(x),\] where for $i=1,2,3$ and $j=1,2$ we define $Z_{i,j}(x)=\frac{x_{i,j}}{x_{i,1}+x_{i,2}}$, and similarly $Q_{2,j}=Z_{1,j}(x)$ and $Q_{3,j}=Z_{2,j}(x)$.  Hence $G_{1,1}(x)=\frac{m}{3}R(Z_{3,1}(x))$, $G_{2,1}(x)=\frac{m}{3}R(Z_{1,1}(x))$ and $G_{3,1}(x)=\frac{m}{3}R(Z_{2,1}(x))$.   We also have, for $i=1,2,3$ and $j=1,2$, $H_{i,j}(x)=\frac{m}{3}\frac{x_{i,j}}{x_{i,1}+x_{i,2}}$, again similarly to Section \ref{period2point}.  Thus 
\begin{align*} F_{1,1}(x) &= \frac{m}{3}(R(Z_{3,1}(x))+Z_{1,1}(x))-2mx_{1,1} \\
F_{2,1}(x) &= \frac{m}{3}(R(Z_{1,1}(x))+Z_{2,1}(x))-2mx_{2,1} \\
F_{3,1}(x) &= \frac{m}{3}(R(Z_{2,1}(x))+Z_{3,1}(x))-2mx_{3,1},\end{align*} with similar expressions for the $F_{i,2}(x)$.

Similarly to Section \ref{period2point}, symmetry implies that the measure $\nu$ from \cite{geopref9} has $\nu_1=\nu_2=\nu_3=\frac13$, so we can consider the dynamics of $F$ restricted to the set $\{x\in \Delta^5: x_{1,1}+x_{1,2}=x_{2,1}+x_{2,2}=x_{3,1}+x_{3,2}=\frac13\}$, meaning that we can take $Z_{i,j}(x)=3x_{i,j}$.  It is then easy to check that any $x$ restricted to this set for which $F(x)=0$ must satisfy $3x_{1,1}=R^3(3x_{1,1})$, and because for our choice of rule $R$ is decreasing the only fixed point is $x=(\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6})$.  At this value of $x$ the restricted Jacobian is $$m\begin{pmatrix}-1 & 0 & R'(\frac12) \\ R'(\frac12) & -1 & 0 \\ 0 & R'(\frac12) & -1\end{pmatrix},$$ whose eigenvalues are $-1$ and $-1-\frac12R'(\frac12)\pm i\frac{\sqrt{3}}{2}R'(\frac12)$.  It follows that this stationary point of $F$ is linearly unstable if $R'(\frac12)<-2$.  For the minority rule with odd $m$, $R(z)=\sum_{j=0}^{(m-1)/2}\binom{m}{j}z^j(1-z)^{m-j}$, with $R'(z)=-m\binom{m-1}{(m-1)/2}z^{\frac{m-1}{2}}(1-z)^{\frac{m-1}{2}}$, so $R'(\frac12)=\frac{-m!}{2^{m-1}((m-1)/2)!)^2}$, which is decreasing in $m$ and is less than $-2$ for $m\geq7$.

In those cases where $(\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6})$ is the only stationary point of $F$ and is linearly unstable, we can apply Theorem 9.1 of Bena\"{\i}m \cite{benaim} to show that convergence to a fixed point has probability zero.  To apply this result we need to show that within a neighbourhood of the fixed point the expectation of the positive part of the noise term $\xi^{(n)}$ in any direction is uniformly bounded away from zero by a constant.  To note that this holds for the minority rule, observe that for $\mathbf{X}_n$ in a suitable neighbourhood of $(\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6})$ the probability that the new vertex is in community $i$ is $\frac13$ and that conditional on this the probability of it being type $j$ is at least $\frac12-\eps$, while if both these events happen the increase in the number of edge ends at vertices of type $j$ in community $i$ is at least $m$, compared with an expected increase of at most $2m\left(\frac16+\eps\right)$.  Therefore $\E((\xi_{i,j}^{n+1})^+|\salj_n)\geq \frac{m}{12}$, say, for a suitably small choice of $\eps$, and as this applies to all choices of $i$ and $j$ the same bound will apply to other directions.  This gives the stated result for the minority rule with $m\geq 7$.


\subsection{Proof of Theorem \ref{linear}}

Define $\hat{Z}^{(n)}_i=\frac{X^{(n)}_{i,1}}{\nu_i}=Z^{(n)}_i\frac{Y^{(n)}_i}{\nu_i}$, where $\nu_i$ is the almost sure limit of $Y^{(n)}_i$ as $n\to\infty$ from Proposition 3.1 of \cite{geopref9}; note that because of this convergence it is sufficient to show convergence of the $\hat{Z}^{(n)}_i$.

In the linear model, for any community $i$ the expected number of new red edge ends in that community at existing vertices is $m\sum_{j=1}^N\mu_j \frac{\alpha_{i,j}Y^{(n)}_iZ^{(n)}_i}{\sum_{k=1}^N\alpha_{k,j}Y^{(n)}_k}$, while the expected number of new red edge ends in the community at the new vertex is $m\mu_i \frac{\sum_{j=1}^N \alpha_{j,i}Y^{(n)}_j Z^{(n)}_j}{\sum_{j=1}^N \alpha_{j,i} Y^{(n)}_j}$.    It follows that 
\begin{equation}\label{zhat}\E(\hat{Z}^{(n+1)}_i|\salj_n)-\hat{Z}^{(n)}_i=\frac{m}{2m(n+n_0+1)\nu_i}\Biggl(\mu_i \frac{\sum_{i=1}^N \alpha_{j,i}Y^{(n)}_j Z^{(n)}_j}{\sum_{i=1}^N \alpha_{j,i} Y^{(n)}_j}+\sum_{j=1}^N\mu_j \frac{\alpha_{i,j}Y^{(n)}_iZ^{(n)}_i}{\sum_{k=1}^N\alpha_{k,j}Y^{(n)}_k}-2\nu_i\Biggr).\end{equation}

From the form of the function $G$ driving the stochastic approximation in \cite{geopref9} and that $G(\nu)$ is zero for the limiting measure $\nu$, it follows that $$\sum_{j=1}^N\mu_j \frac{\alpha_{i,j}\nu_i}{\sum_{k=1}^N\alpha_{k,j}\nu_k}=2\nu_i-\mu_i.$$  Therefore we can write the term in brackets on the right hand side of \eqref{zhat} as 
\[\mu_i \frac{\sum_{i=1}^N \alpha_{j,i}Y^{(n)}_j Z^{(n)}_j}{\sum_{i=1}^N \alpha_{j,i} Y^{(n)}_j}-\mu_iZ^{(n)}_i+\phi_i(Y^{(n)},\nu)Z^{(n)}_i,\]
where for two probability measures $\xi$ and $\eta$ on $S$ \[
\phi_i(\xi,\eta)=\sum_{j=1}^N\mu_j\left(\frac{\alpha_{i,j}\xi_i}{\sum_{k=1}^N\alpha_{k,j}\xi_k}- \frac{\alpha_{i,j}\eta_i}{\sum_{k=1}^N\alpha_{k,j}\eta_k}\right).\]

Hence for any linear combination of the communities we have \begin{multline*}\E\left(\sum_{i=1}^N s_i \hat{Z}^{(n+1)}_i|\salj_n\right)-\sum_{i=1}^N s_i\hat{Z}^{(n)}_i=\frac{m}{2m(n+n_0+1)}\sum_{i=1}^N s_i\mu_i \left(\frac{\sum_{j=1}^N \alpha_{j,i}Y^{(n)}_j Z^{(n)}_j}{\sum_{j=1}^N \alpha_{j,i} Y^{(n)}_j}-Z^{(n)}_i\right)
\\+\sum_{i=1}^N s_i\phi_i(Y^{(n)},\nu)Z^{(n)}_i.\end{multline*}

We aim to find a particular linear combination with coefficients $\sigma_i$, $i=1,\ldots, N$, such that $\sum_{i=1}^N \sigma_i \hat{Z}^{(n)}_i$ would be a martingale if $Y^{(n)}$ were equal to its limit $\nu$.  Because we would then have $\hat{Z}^{(n)}_j=Z^{(n)}_j$ for all $j$, this will be the case if for any values of $x_1,x_2,\ldots,x_N$ we have $$\sum_{i=1}^N \sigma_i \mu_i\left(\frac{\sum_{j=1}^N \alpha_{j,i} \nu_j x_j}{\sum_{j=1}^N \alpha_{j,i} \nu_j}-x_i\right)=0,$$ which is equivalent to $$\sum_{i=1}^N \sigma_i\frac{\mu_i}{\sum_{j=1}^N \alpha_{j,i} \nu_j}\left(\sum_{j=1}^N \alpha_{j,i} \nu_j(x_j-x_i)\right)=0.$$  Define an $N\times N$ matrix $\Psi$ by letting its entries $\psi_{i,j}=\frac{\mu_i \alpha_{j,i}\nu_j}{\sum_{k=1}^N \alpha_{k,i}\nu_k}$ if $i\neq j$ and $\psi_{i,i}=\frac{\mu_i \alpha_{i,i}\nu_i}{\sum_{k=1}^N \alpha_{k,i}\nu_k}-\mu_i$.  Then $\Psi$ is the generator matrix of a continuous time Markov chain on the space of communities with transition rates from community $i$ to community $j$ given by the strength of the connection between the two communities times the proportion of vertices which are in community $i$ times the proportion of edge ends which are in community $j$.  Under our assumptions on the community structure this chain has a unique stationary distribution, which we write as $(\sigma_1,\sigma_2,\ldots,\sigma_N)$.  It follows immediately that $\sum_{i=1}^N \sigma_i\psi_{i,j}=0$ for all $j$, thus satisfying the condition above.

Write $M_n=\sum_{i=1}^N \sigma_i \hat{Z}^{(n)}_i$.  Then, choosing suitable values of $\eps$ and $K$ and assuming $Y^{(n)}_i>\eps$, which occurs for sufficiently large times if $\eps$ is small enough, \[|\E(M_{n+1}|\salj_n)-M_n|\leq Kn^{-1}\sum_{i=1}^N \left|Y^{(n)}_i-\nu_i\right|.\]
To estimate the right hand side here we need to apply results on the rates of convergence of Robbins-Monro stochastic approximation processes to the process in \cite{geopref9} which gives the values of the $Y^{(n)}_i$.  For this we use Proposition 2.3 of Dereich and M\"{u}ller-Gronbach \cite{dereich2019general}, for which we need to check that a number of conditions are satisfied, labelled (I) to (III) and A.1 and A.2 in \cite{dereich2019general}.  Conditions (I) to (III) follow from the fact that we have a stochastic approximation process, and in particular, following their notation, we have $R_n=0$ and $\gamma_n=\frac{1}{n+1+e_0/m}$, where $e_0$ is the number of edges in the initial graph.  That $R_n=0$ means we can also take the $\eps_n$ in the notation of \cite{dereich2019general} (and hence also $e_{k,n}(r)$) as being zero.  That condition A.2 is satisfied follows from the boundedness of the noise terms.  That condition A.1 is satisfied with some $L>0$ follows from the strict convexity of the Lyapunov function in \cite{geopref9}.

To apply Proposition 2.3 of \cite{dereich2019general} we need to estimate $\tau_{k,n}(r)=\prod_{j=k+1}^n (1-\gamma_j r)=\Theta((n/k)^{-r})$ and $s_{k,n}^2(r)=\sum_{j=k}^n \gamma_j ^2\tau_{j,n}(r)^2=\Theta(n^{2r}k^{-2r-1})$.  Then for $0<r<\min\{\frac12,L\}$, $\tau_{j,n}(r)=\Theta((n/j)^{-r})$ and $s_{k,n}^2(r)=\Theta(n^{-2r})$ so Proposition 2.3 of \cite{dereich2019general} thus gives that the $L^p$ norm of the difference between the stochastic approximation process and its limit is $O(n^{-r})$.

Define $\tilde{M}_n=M_n-\sum_{j=2}^m (\E(M_{j}|\salj_n)-M_{j-1})$; it immediately follows from the above that $(\tilde{M}_n)$ is a martingale, and that the expectation of the difference between the increments of $(M_n)$ and $(\tilde{M}_n)$ at time $n$ is $O(n^{-(1+r)})$, which is summable.  Hence $M_n$ converges almost surely, to a random limit $M$, as $n\to\infty$.

To show that the proportions of red in each community all converge to the same limit, note that, because $\Psi$ is the generator matrix of a finite state continuous time Markov chain, for any row vector $s\in \R^N$ we have that the sum of the elements in $s\Psi$ is zero, and thus the $(N-1)$-dimensional subspace of row vectors whose elements sum to zero is preserved under $\Psi$.  Furthermore, by our assumptions on the community structure, the multiplicity of $0$  as an eigenvalue of $\Psi$ is $1$ and all other eigenvalues are strictly negative; let $-\lambda_2<0$ be the largest eigenvalue of $\Psi$ other than $0$ and let $-\lambda_N$ be the smallest eigenvalue of $\Psi$.

Then for any row vector $s\in \R^N$ whose elements sum to zero, we have 
\[\E\left(\sum_{i=1}^N s_i\hat{Z}^{(n+1)}_i|\salj_n\right)-\sum_{i=1}^N s_i\hat{Z}^{(n)}_i \leq \frac{-\lambda_2 m}{2m(n+n_0+1)}\sum_{i=1}^N s_i \hat{Z}^{(n)}_i+Kn^{-1}\sum_{i=1}^N \left|Y^{(n)}_i-\nu_i\right|,\] and \[\E\left(\sum_{i=1}^N s_i\hat{Z}^{(n+1)}_i|\salj_n\right)-\sum_{i=1}^N s_i\hat{Z}^{(n)}_i \geq \frac{-\lambda_N m}{2m(n+n_0+1)}\sum_{i=1}^N s_i Z^{(n)}_i-Kn^{-1}\sum_{i=1}^N \left|Y^{(n)}_i-\nu_i\right|,\] again for a suitable choice of $K$ and sufficiently large times.  By using inequality versions of standard stochastic approximation results (for example Lemma 5.4 of Jordan and Wade \cite{jordanwade}) it follows that $\sum_{i=1}^N s_i\hat{Z}^{(n)}_i \to 0$, almost surely.  For $i\neq j$, this applies to $s=e_i-e_j$ (where $e_i$ and $e_j$ are standard unit vectors) and so shows that $Z^{(n)}_i-Z^{(n)}_j\to 0$ almost surely.  Putting this together with our previous conclusion on $\sum_{i=1}^N \sigma_i\hat{Z}^{(n)}_i$, we have $Z^{(n)}_i \to M$ almost surely as $n\to\infty$.


\section{Examples}\label{examples}

We now consider some examples of community structures and type assignment rules where we can apply our results and compare them with the results for standard preferential attachment which can be deduced from \cite{AMR}; we also show some simulations which illustrate them.  In some cases we can calculate stationary points explicitly and hence give explicit phase transitions.

\subsection{Symmetric community structure, majority wins rule}\label{majwins}

One example of a community structure whose solution is explained in detail in \cite{geopref9} is where there is a two-point space $S=\{1,2\}$ with a simple symmetric attractiveness function given by, in the notation of Theorem \ref{different}, \[A_1=\begin{pmatrix}1 & 1 \\ 1 & 1 \end{pmatrix},\] leading to the matrix $A_{\theta}$ having the form \[A_{\theta}=\begin{pmatrix}1 & \theta \\ \theta & 1\end{pmatrix}.\] Here $\theta$ can be thought of as describing the strength of the connection between the two communities; in particular if $\theta=0$ the communities evolve separately, with no connections developing, while if $\theta=1$ vertices have no preference to connect to their own community or the other one so the graph effectively evolves as standard preferential attachment.  Here $\mu_1$ and $\mu_2=1-\mu_1$ give the relative sizes of the two communities.  In this case the limiting proportions $\nu_i$ of edge ends in each community can be found by solving (2.3) in \cite{geopref9}; there is no closed form solution in general, but in the case $\mu_1=\mu_2=1/2$ it is easy to see that $\nu_1=\nu_2=1/2$.

The \emph{majority wins} rule means that the new vertex connects to $m$ existing vertices and takes the type of the majority of them.  (If $m$ is even, then ties will be broken randomly.)  Here we consider it with $m=3$, but it can also be considered with other values of $m$.  This gives $p_0=p_1=0, p_2=p_3=1$, and so $R(z)=3z^2(1-z)+z^3$ with stable fixed points at $z=0$ and $z=1$ and an unstable fixed point at $z=\frac12$. Hence the results of \cite{AMR} show that for standard preferential attachment the proportion of red vertices tends to either 0 or 1, each with positive probability.  The question then arises of whether, with two communities, the proportion of red vertices in those two communities will tend to the same limit, and Theorem \ref{different} shows that there exists $\theta_{\mathrm{crit}}>0$ such that for $\theta<\theta_{\mathrm{crit}}$ there is positive probability that this does not happen and that different limits occur in the two communities.

In the case $\mu_1=\mu_2=\frac12$, a limit for the stochastic process $(\mathbf{X})_n$ must be of the form $(y_1,\frac12-y_1,y_2,\frac12-y_2)$.  In this case, it is possible to explicitly solve the equations to find all the possible stationary points of this form and classify their stability; this work appears in the third author's PhD thesis \cite{yarrowthesis}.  The stationary points are given in Table \ref{statpoints}, where \begin{align*}
	S&=3\theta^3-9\theta^2+3\theta-1,\\
	R&=(\theta-1)\sqrt{-(7\theta-1)(\theta+1)^3},\\
	U&=(\theta-1)^3.
\end{align*}
\begin{table}[ht]
	\centering
	\begin{tabular}{lll}
		&$y_1$ & $y_2$\\\hline
		1)&$\frac{1}{4}+\frac{(\theta+1)}{4(\theta-1)}\sqrt{\frac{5\theta-1}{\theta-1}}$ & $\frac{1}{4}-\frac{(\theta+1)}{4(\theta-1)}\sqrt{\frac{5\theta-1}{\theta-1}}$\\
		2)&$\frac{1}{4}-\frac{(\theta+1)}{4(\theta-1)}\sqrt{\frac{5\theta-1}{\theta-1}}$ & $\frac{1}{4}+\frac{(\theta+1)}{4(\theta-1)}\sqrt{\frac{5\theta-1}{\theta-1}}$\\
		3)&$0$ & $0$\\
		4)&$\frac{1}{2}$ & $\frac{1}{2}$\\
		5)&$\frac{1}{4}$ & $\frac{1}{4}$\\
		6)&$\frac{1}{4}+\frac{\sqrt{2}}{8}\sqrt{\frac{S+R}{U}}$ & $\frac{1}{4}-\frac{\sqrt{2}}{8}\sqrt{\frac{S-R}{U}}$\\
		7)&$\frac{1}{4}-\frac{\sqrt{2}}{8}\sqrt{\frac{S+R}{U}}$ & $\frac{1}{4}+\frac{\sqrt{2}}{8}\sqrt{\frac{S-R}{U}}$\\
		8)&$\frac{1}{4}+\frac{\sqrt{2}}{8}\sqrt{\frac{S-R}{U}}$ & $\frac{1}{4}-\frac{\sqrt{2}}{8}\sqrt{\frac{S+R}{U}}$\\
		9)&$\frac{1}{4}-\frac{\sqrt{2}}{8}\sqrt{\frac{S-R}{U}}$ & $\frac{1}{4}+\frac{\sqrt{2}}{8}\sqrt{\frac{S+R}{U}}$
	\end{tabular}
	\caption{Stationary points for the flow for the symmetric $m=3$ majority wins model.}
	\label{statpoints}
\end{table}

The stationary points given by 3), 4) and 5) exist for all $\theta$.  Stationary points 1) and 2) are real and have $0\leq y_1\leq \frac12$ and $0\leq y_2\leq \frac12$ if and only if $0\leq \theta\leq \frac15$, while stationary points 6) to 9) are real and have $0\leq y_1\leq \frac12$ and $0\leq y_2\leq \frac12$ if and only if $0\leq \theta\leq \frac17$.

Restricted to the plane of points of the form $(y_1,\frac12-y_1,y_2,\frac12-y_2)$, the eigenvalues of the Jacobian of $F$ at $x=(x_{1,1},x_{1,2},x_{2,1},x_{2,2})=(y_1,\frac12-y_1,y_2,\frac12-y_2)$ are
\[
	\lambda=-3+\frac{9}{1+\theta}\left(J\pm\sqrt{J^2-4K}\right)
\]
where
\[
J=Q_{1,1}(x)\left(1-Q_{1,1}(x)\right)+Q_{2,1}(x)\left(1-Q_{2,1}(x)\right)
\]
and
\[
K=Q_{1,1}(x)Q_{2,1}(x)\left(1-Q_{1,1}(x)\right)\left(1-Q_{2,1}(x)\right)\left(1-\theta^2\right).
\]

Using this, the stationary points 3) and 4) are stable for all values of $\theta$.  Convergence to 3) represents type 2 dominating in both communities, and convergence to 4) represents type 1 dominating in both communities.  Meanwhile the stationary point 5), which corresponds to equal proportions of each type in both communities, is linearly unstable for all values of $\theta$, and stationary points 6) to 9) are linearly unstable for all values of $\theta$ for which they are meaningful.  However, the stationary points 1) and 2) turn out to be linearly stable when $\theta<\frac17$, and linearly unstable for $\frac17<\theta\leq \frac15$. 

Applying Theorem 2.16 of Pemantle \cite{pemantlesurvey} shows that the stable stationary points have positive probability of being limits and applying Theorem 2.17 of \cite{pemantlesurvey} shows that the linearly unstable stationary points have probability zero of being limits. Thus the stationary points 1) and 2) are limits with positive probability when $\theta<\frac17$ but with probability zero when $\theta>\frac17$.  These show the majority of edge ends in one community being of vertices of one type, and the majority of edge ends in the other community being of the other type; in each case there are a small (but $\Theta(n)$) number of vertices of the other community's type present.  Hence for this model the value $\theta_{\mathrm{crit}}$ in Theorem \ref{different} is $\frac17$: for $\theta<\frac17$ it is possible to have different limits in the two communities. 

Examples of simulations with 1000 vertices and these parameters, with $\theta=0.05$, one with different types dominating in the two communities and one with the same type dominating in both, are shown in Figure \ref{commsdiff}.  The graphs were created using the \texttt{igraph} package in R \cite{igraph}, and plotted using the Fruchterman-Reingold layout, which with these parameters naturally shows the communities.

\begin{figure}[ht]
	\centering\begin{tabular}{cc}
		\scalebox{0.5}{\includegraphics[trim=4cm 0.5cm 4cm 0.5cm, clip=true]{communitiesdifferent}} & \scalebox{0.5}{\includegraphics[trim=4cm 0.5cm 4cm 0.5cm, clip=true]{communitiessame}}
	\end{tabular}
	\caption{Examples of simulations with two weakly linked communities and $m=3, p_0=p_1=0,p_2=p_3=1$.  In the left simulation different types are dominating in the two communities, with proportions of red vertices in the two communities being $0.877$ and $0.077$.  In the right simulation blue appears to be dominating in both communities, with proportions of red vertices in the two communities being $0.057$ and $0.021$.\label{commsdiff}}
\end{figure}


\subsection{Symmetric community structure, random visible type}\label{randvis}

Here we consider the same community structure as in section \ref{majwins} but the new vertex now picks one of the types it is exposed to uniformly at random.  Hence $p_0=0$, $p_1=p_2=\frac12$ and $p_3=1$, with $R(z)=\frac32(z(1-z)^2+z^2(1-z))+z^3$, with a stable fixed point at $z=\frac12$ and unstable fixed points at $z=0$ and $z=1$.  In this case the results of \cite{AMR} show that in standard preferential attachment the proportion of red tends to $\frac12$ almost surely, and a corresponding result was shown to hold for any number of types and any $m\geq 3$ in \cite{threetypes}.  This rule is increasing, and the only fixed points of $R(z)$ in $[0,1]$ are $z=0$, $z=1/2$ and $z=1$, with the first and last being linearly unstable ($R'(0)=R'(1)=3/2$). Consequently Theorem \ref{same} shows that the same will apply for the multi community model, regardless of the community structure. Analysis of the stationary points in this case with community structure given by \[A_{\theta}=\begin{pmatrix}1 & \theta \\ \theta & 1\end{pmatrix}\] also appears in \cite{yarrowthesis}, again for $\mu_1=\mu_2=\frac12$, and as might be expected from Theorem \ref{same} the only stable stationary point is $(\frac14,\frac14,\frac14,\frac14)$, regardless of the value of $\theta$.  So in this case there is no phase transition in $\theta$.


\subsection{Only one possible limit with a single community, different limits in different communities}

Theorem \ref{determinant}, part 2, implies that there are examples which that result applies to with the community structure given by $$A=\begin{pmatrix} 1 & \theta \\ \theta & 1\end{pmatrix},$$ but with $\theta>1$, indicating that vertices in fact prefer to connect to vertices in the \emph{other} community.  For example, consider this community structure with $\theta=10$, and take $m=3$ with the ``minority rule'': the new vertex chooses to take the type which is less common among its neighbours, giving $p_k=1$ for $k=0,1$ and $p_k=0$ for $k=2,3$.  Here $R(z)=(1-z)^3+3z(1-z)^2$ with a single, stable, fixed point at $z=\frac12$, so for standard preferential attachment the proportion of red converges to $\frac12$ almost surely.  However, with the above community structure this rule is covered by part 2 of Theorem \ref{determinant} and so shows positive probability of different limits in the two communities.  An example of a simulation with 500 vertices and this rule appears in Figure \ref{minoritya10}, showing different types dominating in the two communities.

\begin{figure}[ht]
	\centering
	\scalebox{0.7}{\includegraphics[trim=6cm 2cm 6cm 1cm, clip=true]{minority_two_comm_a10}}
	\caption{Example simulation showing different type dynamics in two communities in a case where a single community converges to the same limit.  The left community has a proportion $0.840$ of its vertices being red, and the right community a proportion $0.151$ of its vertices being red. \label{minoritya10}}
\end{figure}

\subsection{Example with a touchpoint and an invisible community}

We consider the rule with $m=3, p_0=1/4, p_1=0, p_2=p_3=1$; for this case $R(z)=\frac14(1-z)^3+3z^2(1-z)+z^3$ and has a touchpoint at $z=\frac13$ and a stable fixed point at $z=1$, so in the single community model the results of \cite{AMR} will give both $\frac13$ and $1$ as possible limits for the proportion of red vertices.  Proposition \ref{touchpoint} shows that if the community structure matrix $A$ has all entries positive then for small $\theta$ we do not get convergence to different limits here.  However, if one community is invisible to the other this does not apply.

Consider an asymmetric community structure where, in the notation of Theorem \ref{different} \[A_{\theta}=\begin{pmatrix} 1 & 0 \\ \theta & 1\end{pmatrix},\] with $\theta>0$, so that one community (the one labelled 1) is invisible to the other, but the other community is visible to both.  We take $\mu_1=\frac45$ and $\mu_2=\frac15$, so that the invisible community is larger. Figure \ref{touchpoint_invisible} shows an example of a simulation with the type assignment rule described in the last paragraph and this community structure; in this simulation the visible community is close to the touchpoint, but the invisible community is close to the stable root.  Note that it intuitively makes sense that when the invisible community is relatively small it is likely to take the visible community's type, but when it is larger, as here, it is easier for it to maintain its own type dynamics.

\begin{figure}
	\centering
	\scalebox{0.7}{\includegraphics[trim=6cm 2cm 6cm 2cm, clip=true]{touchpoint_invisible}}
	\caption{Here the larger invisible community has a proportion $0.923$ of its vertices red, while the smaller visible community has a proportion $0.269$ of its vertices red, suggesting that the latter may be converging to the touchpoint at $1/3$. \label{touchpoint_invisible}}
\end{figure}



\section*{Acknowledgements}

J.H. was supported during this project by the UK Research and Innovation Future Leaders Fellowship MR/S016325/1 and by the European Research Council under the European Union's Horizon 2020 research and innovation programme (grant agreement no.\ 883810). 

Part of this research was carried out during two visits of J.H. to the School of Mathematics and Statistics (SoMaS) in the University of Sheffield, funded by the Heilbronn Institute for Mathematical Research (HIMR) via a Heilbronn Small Grant award. We are grateful to HIMR for this support and to SoMaS for its hospitality.


