2

Suppose you have several random graphs. Each one has $n$ nodes, connected among them with probability $p$. There are $r$ random graphs. Now, each node is connected to nodes of another random graph with probability $q$, in general different from $p$. Suppose that any node is a friend of anybody to whom he is either directly connected to by an edge, or by anyone with whom they share an endnode, i.e. anyone with whom there exists a path of length at most 2.

First question: How many friends each node has in expectation?

Second question: now suppose that half nodes in each graph are men, half women. How many expected women friends each male node has?

The answer must be a generalization of this one: Probability of friendship

Furthermore, the probability that node x is not a friend of someone in his own graph is something like

$(1-p) \sum^n_k \sum^{r(n-1)}_h p^k q^h (1-p)^{n-k} (1-q)^{(r-1)n-h} (1-p)^{k} (1-q)^{h}$

and the probability that node x is not a friend of someone in a different graph is something like

$(1-q) \sum^n_k \sum^{r(n-1)}_h p^k q^h (1-p)^{n-k} (1-q)^{(r-1)n-h} (1-p)^{k} (1-q)^{h}$

but in both cases I am missing a combinatorial factor.

fox
  • 521
  • I would approach this problem by considering the adjacency matrix of the graph. Depending on how you count the paths of length 2, you may need to exclude the cases where the path ends where it begins. These are just going back and forth on the same edge, and depending on your definition a "walk" like this might not be a valid path. – hardmath May 05 '18 at 18:08

2 Answers2

2

It is easier to understand the probability that, given a node $v$, another node $w$ is not connected to it by a path of length $1$ or $2$.

For example, to answer question $2$, we can assume both nodes $v$ and $w$ are in the same $n$-vertex graph. In that case,

  • There is no edge $vw$, which happens with probability $(1-p)$.
  • For any node $x$ in the same $n$-vertex graph, edges $vx$ and $wx$ are not both present, which happens with probability $1-p^2$.
  • For any node $x$ in another $n$-vertex graph, edges $vx$ and $wx$ are not both present, which happens with probability $1-q^2$.

Combining these, there is a probability $$(1-p)(1-p^2)^{n-2}(1-q^2)^{n(r-1)}$$ that there is not a path of length $1$ or $2$ between $v$ and $w$. So the expected number of vertices in the same $n$-vertex graph that do have such a path is $$(n-1)\left(1 - (1-p)(1-p^2)^{n-2}(1-q^2)^{n(r-1)}\right)$$ which is the number of other vertices in the same $n$-vertex graph multiplied by the probability that each one of them has such a path.

We can find the expected number of vertices connected to $v$ in other $n$-vertex graphs in a similar way.

Misha Lavrov
  • 159,700
  • Thanks Misha. What I want to understand is: choose a vertex $x$. Let his friends be those with whom he is connected by a path of length at most 2. The questions is how many friends does he have? And how many of them belong to another random graph? – fox May 10 '18 at 17:31
  • I am also quite confused about the $1-p^2$. Why are we looking at the probability that NONE of the two edges are present? As long as just one edge is not there the original nodes $v$ and $w$ are not connected. – fox May 10 '18 at 17:33
  • $1 - p^2$ is saying not both of the edges are present. It allows for one. – Misha Lavrov May 10 '18 at 20:02
  • The answer to the question of how many friends is, in expectation, the number of vertices multiplied by the probability that they're friends. (If you're looking for the distribution, that's a harder question.) – Misha Lavrov May 10 '18 at 20:02
1

I think Misha Lavrov's answer is better than mine, but my approach, though longer, does get the required results . . .

Let $m=n(r-1)$.

For a given member $y$ of your group, other than yourself, let $A$ be the event that you are connected to $y$ by a path of length at most two.

For a given member $z$ of one of the other groups, let $B$ be the event that you are connected to $z$ by a path of length at most two.

Then the expected number of vertices which are connected to you by a path of length at most two is just $$(n-1)P(A)+mP(B)$$ and if $n$ is even, and each group has ${\large{\frac{n}{2}}}$ members of each gender, then the expected number of vertices whose gender is opposite to yours, and which are connected to you by a path of length at most two is just $$\left({\small{\frac{n}{2}}}\right)\!P(A)+\left({\small{\frac{m}{2}}}\right)\!P(B)$$

It remains to compute $P(A)$ and $P(B)$.

Let $A',B'$ denote the complements of $A,B$, respectively (i.e., $A'=\text{not}\,A$, and $B'=\text{not}\,B$). \begin{align*} \text{Then}\;\;P(A') &=(1-p)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left(\sum_{k=0}^{n-2}{\small{\binom{n-2}{k}}}p^k(1-p)^{(n-2)-k}(1-p)^k\right)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left(\sum_{k=0}^m{\small{\binom{m}{k}}}q^k(1-q)^{m-k}(1-q)^k\right)\\[8pt] &=(1-p)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left(\sum_{k=0}^{n-2}{\small{\binom{n-2}{k}}}p^k(1-p)^{n-2}\right)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left(\sum_{k=0}^m{\small{\binom{m}{k}}}q^k(1-q)^m\right)\\[8pt] &=(1-p)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left((1-p)^{n-2}\sum_{k=0}^{n-2}{\small{\binom{n-2}{k}}}p^k\right)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left((1-q)^m\sum_{k=0}^m{\small{\binom{m}{k}}}q^k\right)\\[4pt] &=(1-p)\Bigl((1-p)^{n-2}(1+p)^{n-2}\Bigr)\Bigl((1-q)^m(1+q)^m\Bigr)\\[4pt] &=(1-p)(1-p^2)^{n-2}(1-q^2)^m\\[20pt] \text{and}\;\;P(B') &=(1-q)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left(\sum_{k=0}^{n-1}{\small{\binom{n-1}{k}}}p^k(1-p)^{(n-1)-k}(1-q)^k\right)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left(\sum_{k=0}^{m-n}{\small{\binom{m-n}{k}}}q^k(1-q)^{(m-n)-k}(1-q)^k\right)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left(\sum_{k=0}^{n-1}{\small{\binom{n-1}{k}}}q^k(1-q)^{(n-1)-k}(1-p)^k\right)\\[8pt] &=(1-q)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left(\sum_{k=0}^{n-1}{\small{\binom{n-1}{k}}}\bigl(p(1-q)\bigr)^k(1-p)^{(n-1)-k}\right)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left((1-q)^{m-n}\sum_{k=0}^{m-n}{\small{\binom{m-n}{k}}}q^k\right)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left(\sum_{k=0}^{n-1}{\small{\binom{n-1}{k}}}\bigl(q(1-p)\bigr)^k(1-q)^{(n-1)-k}\right)\\[8pt] &=(1-q)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left(\bigl(p(1-q)+(1-p)\bigr)^{n-1}\right)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left((1-q)^{m-n}(1-q)^{m-n}\right)\\[0pt] &\;\;\;\;\;{\LARGE{\cdot}}\left(\bigl(q(1-p)+(1-q)\bigr)^{n-1}\right)\\[4pt] &=(1-q)(1-pq)^{2n-2}(1-q^2)^{m-n}\\[0pt] \end{align*} Finally, since $P(A)=1-P(A')$, and $P(B)=1-P(B')$, we get \begin{align*} P(A) &= 1-(1-p)(1-p^2)^{n-2}(1-q^2)^m\\[4pt] P(B) &= 1-(1-q)(1-pq)^{2n-2}(1-q^2)^{m-n}\\[4pt] \end{align*} which completes the analysis.

quasi
  • 61,115
  • Wow that is great! And just now I understood Misha's answer. Thanks so much to you both! – fox May 11 '18 at 12:24
  • As a way to verify, think that $q=0$. Then the number of friends of different gender is $n/2[1-(1-p)(1-p^2)^{n-2} ]$. Seems reasonable. But from your answer in the previous post I get $n/2[ 1- (1-p)^{n-1} (1+p)^{n-2} ]$. Are these expressions equivalent? – fox May 11 '18 at 15:35
  • 1
    Yes, they're equivalent, since $$(1-p)(1-p^2)^{n-2}=(1-p)\bigl((1+p)(1-p)\bigr)^{n-2}=(1-p)^{n-1}(1+p)^{n-2}$$ – quasi May 11 '18 at 16:30
  • Suppose $p=1$ for exposition. I had this intuition that I will have the same number of friends belonging to each graph even when $q$ is very small (I do not need $q=1$). The reason is that each extra link connects me to all the friends of that person. I thought this happens roughly at $1/n$ (in fact a smaller threshold). What I am saying is that $P(B)=1$ in expectation for some $q<1/n$, as I have found using computations using the above formulas, but I am unsure how to prove it. – fox May 14 '18 at 11:38
  • @Josué Ortega: I don't follow. What do you mean by "$P(B)=1$ in expectation for some $q < 1/n$"? – quasi May 14 '18 at 18:36
  • I want to find $q$ that makes that everybody has the same friends of each graph. If $p=1$ and $q=1/n$, every agent has one friend from another graph, therefore he is connected to all agents of each graph. Therefore $P(B)=1$. I want to prove this mathematically, – fox May 14 '18 at 20:07
  • So with $p=1$, and $q=1/n$, you want to determine the probability that you are friends with everyone? (where "friends" means connected by a path of length at most $2$) – quasi May 14 '18 at 20:14
  • Yes as a first step, not really thrilled about the $q=1/n$, I just think this probability becomes 1 (or very close) with small values of $q$, I want to find $q$ that makes P(B) almost one, if that makes sense – fox May 14 '18 at 20:22
  • 1
    To explore the issue, let $p=1,;q=1/n$, and let $r=2$ ($2$ groups). Then the probability that you are friends with everyone is exactly $$1-\left(1-\frac{1}{n}\right)^{2n-1}$$ which approaches $$1-e^{-2}\approx .8646647168$$ as $n$ approaches infinity. – quasi May 14 '18 at 20:36
  • I tried to generalize your approach as follows $P(B)=1-(1-q)^{2n-1}(1-q^2)^{(r-2)n}$ $=1-(1-q)^{rn-1}(1+q)^{(r-2)n}$ $=1-(1-\frac{1}{n})^{rn-1}(1+\frac{1}{n})^{(r-2)n}$ $\approx 1- e^{r-2} \approx 1- e^{-r}e^{-2}=.86$ which looks crazy because it does not depend on $r$! – fox May 15 '18 at 23:05
  • Intuitively it makes no sense. When $q=1/n$ each person has in expectation 1 friend from another graph. His friend is fully connected inside the graph, therefore in expectation he is a friend of every agent of that graph. Am I missing something? – fox May 15 '18 at 23:13
  • Expectation needs to take probabilities into consideration. Since the probability of having no friends in a given group is nonzero, the expected number of friends in a given one of the other groups is less than $n$, – quasi May 15 '18 at 23:30
  • Suppose that every man marries a woman to whom they are connected to. Half of the agents are men, half women. How many people are unmarried? – fox May 19 '18 at 17:33
  • You would have to specify how the marriage pairs are selected. – quasi May 20 '18 at 03:51
  • Each node has an associated real number drawn randomly. Agents prefer to marry the node with the associated real number closest to theirs. – fox May 20 '18 at 11:15
  • I'm on my way out, but note: It's not commutative. Male $x$ might prefer to marry female $y$, but not vice-versa. – quasi May 20 '18 at 11:25
  • The marriage is stable: there is no two unmarried agents who prefer each other to their current partner. – fox May 20 '18 at 11:29
  • As I see it, the setup needs to be specified a lot more precisely to allow a formal analysis, and morevover, unless the setup is kept very simple, I suspect that any results will need to come from a simulation (i.e., there won't be a closed-form resolution). – quasi May 20 '18 at 15:01
  • I thought I could use this result from Erdos-Renyi https://math.stackexchange.com/questions/1267387/the-probability-of-having-a-perfect-matching-in-a-bipartite-graph/2500096?noredirect=1#comment5749341_2500096 – fox May 20 '18 at 15:06
  • It's not a closed-form result. – quasi May 20 '18 at 15:11
  • And in any case, your current specification is too vague, even for a simulation. But that's how you should start. Once you figure out a satisfactory setup, run a simulation. – quasi May 20 '18 at 15:12
  • I have formalized my question here https://math.stackexchange.com/questions/2789829/probability-of-having-a-girlfriend-in-a-school-with-groups – fox May 21 '18 at 09:40