- $s$ sends a “Count” message to itself.
- When a node $v$ receives a “Count” message from node $u$, it acts in the following way:
- Send every neighbour except $u$ a “Count” message and wait for the result.
- Send $u$ a “Result” message containing the sum of all results (0 if there are no neighbours).
The problem with general graphs is that we may not remember which nodes we already counted, so we might count the same node twice. What to do?
Asked By : Erel Segal-Halevi
Answered By : Peter
- Each node $u$ generates a random value $x_u$ according to the exponential distribution with rate 1; we round $x_u$ to $Theta(log n)$ bits.
- Node $u$ also has a local variable $minval_u$ where it keeps track of the minimum value encountered so far. Initially, $minval_u = x_u$.
- For the next $Diam(G)$ many rounds, node $u$ sends $minval_u$ to its neighbors. Also, upon receiving $minval_v$ from some neighbor $v$, node $u$ sets $minval_u = min(minval_u,minval_v)$.
- After round $Diam(G)$, node $u$ computes its estimate of the number of nodes as $1/minval_u$.
Why does this algorithm work? Our algorithm exploits the following nice property of the exponential distribution (see here): If we have $n$ exponential random variables $X_1,dots,X_n$ each of rate $1$, then the random variable $X = min(X_1,dots,X_n)$ is also exponentially distributed of rate $n$ and therefore has expected value $1/n$. At the end of the algorithm, the $minval_u$ variable corresponds to a sample of this random variable $X$. Therefore, to get the sought value $n$ (i.e. the number of nodes), we simply compute $1/minval_u$. To get a high probability bound, we can repeat the above $Theta(log n)$ many times and take the average of the produced estimates.
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/42605 Ask a Question Download Related Notes/Documents