Random Connected Graph
Consider the random process of successively adding edges to a graph on n labelled vertices, where each of the C(n, 2) possible edges is equally likely to be chosen at each step (with replacement of...
Problem Statement
This archive keeps the full statement, math, and original media on the page.
Consider a rectangle made up of \(W \times H\) square cells each with area \(1\).
Each cell is independently coloured black with probability \(0.5\) otherwise white. Black cells sharing an edge are assumed to be connected.
Consider the maximum area of connected cells.
Define \(E(W,H)\) to be the expected value of this maximum area. For example, \(E(2,2)=1.875\), as illustrated below.

You are also given \(E(4, 4) = 5.76487732\), rounded to \(8\) decimal places.
Find \(E(7, 7)\), rounded to \(8\) decimal places.
Problem 701: Random Connected Graph
Mathematical Foundation
Let denote the total number of possible edges. At each step an edge is chosen uniformly at random from possibilities. Let denote the random multigraph after steps (duplicate edges are ignored), which is equivalent in distribution to the Erdos—Renyi model with .
Theorem 1 (Erdos—Renyi Connectivity Threshold). Let for a constant . Then
Proof. The probability that vertex is isolated after edge selections is
Substituting :
The expected number of isolated vertices is . By the method of moments (or Chen—Stein), the number of isolated vertices converges in distribution to . Since for large the dominant obstruction to connectivity is the existence of isolated vertices, .
Lemma 1 (Expected Edges via Survival Function). The expected number of edge additions until connectivity equals
Proof. For any non-negative integer-valued random variable , . Here is the first time is connected, and .
Theorem 2 (Asymptotic Ratio). As , , with finite-size corrections of order .
Proof. Write where encodes the correction. From the survival function and the Poisson approximation, the integral of the survival tail beyond the threshold contributes a constant (the Euler—Mascheroni-like correction). Therefore , and since is bounded, . For , numerical evaluation of the survival sum yields .
Editorial
We compute E(n) via numerical summation of survival function. We then p(disconnected) ≈ 1 - exp(-n * (1-p)^(n-1)) (isolated vertex approx). Finally, iterate over large n, use analytic approximation.
Pseudocode
Compute E(n) via numerical summation of survival function
P(disconnected) ≈ 1 - exp(-n * (1-p)^(n-1)) (isolated vertex approx)
For large n, use analytic approximation:
f(n) = 1 + gamma_n / ln(n) where gamma_n → Euler-Mascheroni constant region
Numerical integration of survival function around threshold
This integral equals the Euler-Mascheroni constant γ ≈ 0.5772
Complexity Analysis
- Time: for direct summation of the survival function (the sum has non-negligible terms). The analytic approximation runs in .
- Space: .
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <bits/stdc++.h>
using namespace std;
int main() {
double n = 1e4;
double gamma_em = 0.5772156649;
double E_n = (n / 2.0) * (log(n) + gamma_em);
double baseline = (n / 2.0) * log(n);
double f_n = E_n / baseline;
cout << (long long)(f_n * 1e4) << endl;
return 0;
}
"""
Problem 701: Random Connected Graph
"""
def solve():
import math
n = 10**4
total_edges = n * (n - 1) // 2
# Analytic approximation using Erdos-Renyi threshold
# E(n) ~ (n/2) * (ln(n) + gamma) where gamma ~ 0.5772
gamma_em = 0.5772156649
E_n = (n / 2) * (math.log(n) + gamma_em)
baseline = (n / 2) * math.log(n)
f_n = E_n / baseline
return int(f_n * 10**4)
answer = solve()
print(answer)