Broken Bridges

John lives in the Trees of Ten Houses, and it is a most ideal and idyllic place for him and the other dwellers up in the canopy. They have invested a tremendous amount of time in engineering these houses, and to ensure no house felt isolated from the others, they built a fresh, finely crafted bridge between each and every house!

Unfortunately, the Trees of Ten Houses were not immune to thunderstorms, nor were the bridges well engineered. The night was treacherous, howling with wind and freezing with rain, so the odds for the bridges were not good--each bridge seemed just as likely to survive as to be shattered!

Fortunately, as there were so very many bridges in the Trees of Ten Houses, when John did wake the following morning, he found he was able to make his way to each and every house using only the existing bridges, though round-about routes may have been necessary. As they began rebuilding, John became curious... what were the chances that they'd all be so lucky?

More formally, if P P is the probability that, after the storm, John is able to traverse to each and every house, what is 1 0 10 P ? \big\lfloor 10^{10} P \big\rfloor?

Details and Assumptions:

  • The Trees of Ten Houses do, in fact, contain precisely 10 houses.
  • Before the storm, there exists a single bridge between each and every unique pair of houses.
  • The storm destroys each bridge with independent probability 1 2 \frac{1}{2} .
  • John is allowed to traverse through others' houses to try to reach all of them, but he must only use the surviving bridges to get there. No vine swinging allowed.

Tagged under #ComputerScience as this problem is quite tedious to do without it, though not impossible.
Image Credit: http://hdscreen.me/wallpaper/2645876-bridges-fantasy-art-landscapes-mountains


The answer is 9804491752.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Daniel Ploch
Aug 13, 2014

Let's model the village as an undirected graph, with 10 nodes, and, initially, 45 edges for bridge completeness. We are looking for the probability that, if each edge is removed with independent probability 50%, the graph remains connected. Since we require 10 digits of precision, Monte Carlo methods are not going to help us, and since there are, counting isomorphisms, 2 45 2^{45} such graphs, direct counting isn't going to help either!


The first bit we need to understand is that every possible graph is equally likely . That is, by simply numbering the edges of the graph, any number-labeled configuration of edges that remain and edges that are destroyed can occur with probability 2 45 2^{-45} . So, if we are able to compute the total number of possible connected graphs, then we can easily compute the probability that our graph is one of them.

We'll let T ( n ) T(n) be the total number of graphs of size n n , with vertices labeled { 1 , 2 , 3 , . . . , n } \{1, 2, 3, ..., n\} . Let C ( n ) C(n) be the total number of connected graphs of size n n , and let D ( n ) D(n) be the total number of disconnected graphs of size n n . We find that:

T ( n ) = 2 ( n ( n 1 ) 2 ) T(n) = 2^{\left( \frac{n(n-1)}{2} \right)}

C ( n ) = T ( n ) D ( n ) C(n) = T(n) - D(n)

D ( n ) = k = 1 n 1 ( n 1 k 1 ) C ( k ) T ( n k ) D(n) = \sum_{k=1}^{n-1} {\binom{n-1}{k-1} \cdot C(k) \cdot T(n-k)}

That last definition is the most interesting one, as it allows us to actually compute C ( 10 ) C(10) , which we need to get P P . Let's break it down a bit:

  • A disconnected graph is the union of 2 or more connected components whose vertices are disjoint.
  • Suppose vertex 1 1 in a graph of size n n is in a connected component of size k k , and let that component be fixed. There are thus precisely T ( n k ) T(n-k) ways to populate the remainder of the graph.
  • To make a connected component of size k k , we need k 1 k-1 nodes to add to node 1 1 . There are ( n 1 k 1 ) \binom{n-1}{k-1} ways to choose these nodes.
  • With the nodes chosen, there are C ( k ) C(k) ways to actually connect them all.
  • Thus, there are ( n 1 k 1 ) C ( k ) T ( n k ) \binom{n-1}{k-1} \cdot C(k) \cdot T(n-k) ways to construct a disconnected graph of size n n such that vertex 1 1 lives in a connected component of size k k .
  • Sum over all possible k k , and we get D ( n ) D(n) .

The scale of the problem is such that we don't need to cache values for C ( n ) C(n) or D ( n ) D(n) to compute C ( 10 ) C(10) in reasonable time, as it is a mere 10 2 10 10 \cdot 2^{10} operations to do so. Using dynamic programming, however, would allow us to compute such outlandish values as C ( 100 ) C(100) and D ( 1000 ) D(1000) instantly.

The answer is thus, simply:

1 0 10 C ( 10 ) T ( 10 ) = 9804491752 \left\lfloor 10^{10} \cdot \frac{C(10)}{T(10)}\right \rfloor = \boxed{9804491752}


So John and company actually have a healthy 98% chance of remaining fully connected after the storm. Ten houses seems quite ideal indeed!


Update: Apparently C ( n ) C(n) is defined in OEIS . So, if you're skeptical, just grab a ( 10 ) a(10) from over there, divide by 2 45 2^{45} with a calculator, and see the decimal representation of P P for yourself.

I have to admit this is a very nice question and I enjoy it very much. Truth be told, it takes all my time on Sunday to solve this question since I have no clue what is a graph theory. My first idea used binomial probability since we have ( 10 2 ) \binom{10}{2} independent trials and probability 1 2 \frac12 . At least we need 9 9 bridges survive, but the hardest part is how to determine the right bridges to survive i.e. the bridges that can connect all the houses. The second idea was I combined the first approach with the Erdős–Rényi model , G ( n , p ) G(n,p) model, and I got the probability of the remaining bridges can connect all the houses (the general approach) Pr [ n , p ] = 1 k = 1 n 1 ( n 1 k 1 ) Pr [ k , p ] ( 1 p ) k ( n k ) . \Pr[n,p] = 1 - \sum_{k=1}^{n-1} \binom{n-1}{k-1} \Pr[k,p] (1-p)^{k(n-k)}. Setting n = 10 n=10 and p = 1 2 p=\frac12 , we obtain Pr [ 10 , 1 2 ] = 1 k = 1 9 ( 9 k 1 ) Pr [ k , 1 2 ] ( 1 1 2 ) k ( 10 k ) 0.980449175211106. \begin{aligned} \Pr\left[10,\frac12\right] &= 1 - \sum_{k=1}^{9} \binom{9}{k-1} \Pr\left[k,\frac12\right]\left(1-\frac12\right)^{k(10-k)}\\ &\approx0.980449175211106. \end{aligned}

Tunk-Fey Ariawan - 6 years, 9 months ago

Please can you explain why are there 2^45 graphs ? with isomorphisms and stuff..

Ayman Hjirt - 1 year, 10 months ago

Log in to reply

There are C(10,2) edges (i.e bridges) because each pair of houses is connected, so we're counting number of such pairs, which is 45. After the storm, each configuration is obtained by choosing some subset of those 45 bridges. Each bridge can either survive or be destroyed. It's like you have 45 binary places and ask how many binary numbers can be represented.

lovro cupic - 1 year, 7 months ago
Kaustubh Pardeshi
Oct 28, 2018

I wrote some code to solve this problem. Have a look at the repository https://github.com/kpardeshi/Broken-Bridges

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...