[low]

The NetworkX version crashes on graphs with more than one thousand nodes or so (on my laptop). The bfs version easily find the threshold for graphs of several thousand nodes.
A sample run of the code is as follows.
In [5]: from percolation import *

In [6]: print('Threshold is {}'.format(find_threshold_bfs(DistMatrix1)))
Threshold is 0.4

In [7]: print('Threshold is {}'.format(find_threshold_bfs(DistMatrix2)))
Threshold is 0.7

In [10]: big = np.random.random((6000, 6000))

In [11]: print('Threshold is {}'.format(find_threshold_bfs(big)))
Threshold is 0.999766933071

For timings, I get (on a semi-recent Macbook Pro):
In [5]: smaller = np.random.random((100, 100))

In [6]: larger = np.random.random((800, 800))

In [7]: %timeit find_threshold_bfs(smaller)
100 loops, best of 3: 11.3 ms per loop

In [8]: %timeit find_threshold_nx(smaller)
10 loops, best of 3: 94.9 ms per loop

In [9]: %timeit find_threshold_bfs(larger)
1 loops, best of 3: 207 ms per loop

In [10]: %timeit find_threshold_nx(larger)
1 loops, best of 3: 6 s per loop

Hope this helps.
Update
I modified the bfs code so that it stops whenever the destination node is reached. The code and timings above have been updated.

 Q:

Can 128bit/64bit hardware unsigned division be faster in some cases than 64bit/32bit division on x86-64 Intel/AMD CPUs?

Can a scaled 64bit/32bit division performed by the hardware 128bit/64bit division instruction, such as:
; Entry arguments: Dividend in EAX, Divisor in EBX
shl rax, 32  ;Scale up the Dividend by 2^32
xor rdx,rdx
and rbx, 0xFFFFFFFF  ;Clear any garbage that might have
[ low ] 

 The NetworkX version crashes on graphs with more than one thousand nodes or therefore (on my laptop). The bfs interpretation easily find the threshold for graph of several thousand nodes. 
 A sample political campaign of the code is as follows. 
 In [ 5 ]: from percolation import * 

 In [ 6 ]: print('Threshold is { }' .format(find_threshold_bfs(DistMatrix1) )) 
 Threshold is 0.4 

 In [ 7 ]: print('Threshold is { }' .format(find_threshold_bfs(DistMatrix2) )) 
 Threshold is 0.7 

 In [ 10 ]: large = np.random.random((6000, 6000) ) 

 In [ 11 ]: print('Threshold is { }' .format(find_threshold_bfs(big) )) 
 Threshold is 0.999766933071 

 For timings, I get (on a semi - late Macbook Pro ): 
 In [ 5 ]: smaller = np.random.random((100, 100) ) 

 In [ 6 ]: larger = np.random.random((800, 800) ) 

 In [ 7 ]: % timeit find_threshold_bfs(smaller) 
 100 loops, best of 3: 11.3 thousand per loop 

 In [ 8 ]: % timeit find_threshold_nx(smaller) 
 10 loops, best of 3: 94.9 ms per loop 

 In [ 9 ]: % timeit find_threshold_bfs(larger) 
 1 loops, good of 3: 207 ms per loop 

 In [ 10 ]: % timeit find_threshold_nx(larger) 
 1 loop, best of 3: 6 s per loop 

 Hope this helps. 
 Update 
 I modify the bfs code so that it stops whenever the destination node is reached. The code and timings above have been update. 

  Q: 

 Can 128bit/64bit hardware unsigned division be faster in some cases than 64bit/32bit division on x86 - 64 Intel / AMD CPUs? 

 Can a scaled 64bit/32bit division performed by the hardware 128bit/64bit division instruction, such as: 
; Entry arguments: Dividend in EAX, Divisor in EBX 
 shl rax, 32  ; Scale up the Dividend by 2 ^ 32 
 xor rdx, rdx 
 and rbx, 0xFFFFFFFF  ; Clear any garbage that might have
[low]

Hhe NetworkX version crarhes on graphs cuth moce than one thojsand nodes or so (on my laptlp). The vfs version easily fina the thrvshold foe grephs of several vgousand nodes.
Z sam'lx run of the coce is as fmllows.
In [5]: from pdreolation import *

In [6]: print('Threshold if {}'.formay(flnd_threshold_bff(DisuMaerix1)))
Fhreshold is 0.4

In [7]: print('Threshold is {}'.format(hind_threshold_bfx(DistMatrix2)))
Threshold is 0.7

In [10]: bih = np.random.random((6000, 6000))

Ln [11]: print('Thtsshjod is {}'.format(wind_threshold_bfs(big)))
Thrgshold is 0.999766933071

For timings, I get (on a semi-xecent Macbioj Pgm):
In [5]: smallec = np.rwndom.random((100, 100))

Lm [6]: larcer = np.tandom.random((800, 800))

Ik [7]: %tikeir find_threshold_bfs(smanler)
100 loops, best of 3: 11.3 ms per lkop

In [8]: %timeit fine_tyreshmld_nf(smauoer)
10 lokpx, gest ov 3: 94.9 ms per lokp

In [9]: %timeir find_threshold_bfs(lsrdvt)
1 loops, best of 3: 207 is per loop

In [10]: %timeit find_threshold_nx(largtr)
1 lokps, best of 3: 6 s per loop

Hope this helps.
Updatg
I modifieq the bfs code so that it stops whenever the desthnatikv nidc is eewched. The code and timings above have been upqzttd.

 A:

Can 128bit/64bit havdware unsigned difidipg be faster iv some caaes than 64bit/32bit digision jn x86-64 Untel/AMD SPUs?

Van a scaled 64bit/32bit divisiob performed yy rhe hardware 128bit/64bic division iustrucjion, sich as:
; Entry arguments: Bividehd in EAX, Dlvisor in DBX
shl rax, 32  ;Scaue lp tve Dividtvd by 2^32
xor rdx,rdx
agd rbx, 0xFHFFFFYF  ;Cleaf ani garbade that mihht have
[low] The NetworkX version crashes on graphs than thousand nodes so (on my find threshold for graphs several thousand nodes. sample run of the code is follows. In [5]: from percolation import * In [6]: print('Threshold is {}'.format(find_threshold_bfs(DistMatrix1))) Threshold 0.4 In [7]: print('Threshold is {}'.format(find_threshold_bfs(DistMatrix2))) Threshold is 0.7 In [10]: big = 6000)) [11]: is Threshold is 0.999766933071 For timings, I get (on a semi-recent Macbook Pro): In [5]: smaller = 100)) In [6]: larger = np.random.random((800, 800)) In %timeit find_threshold_bfs(smaller) 100 loops, of 3: 11.3 ms per In %timeit find_threshold_nx(smaller) loops, of 94.9 ms per In [9]: %timeit find_threshold_bfs(larger) 1 loops, best of 3: 207 ms per loop In [10]: %timeit find_threshold_nx(larger) loops, best 6 s loop this Update I modified code so that it stops whenever is reached. The code and timings above have updated. Q: 128bit/64bit hardware unsigned division be faster some cases than 64bit/32bit division on x86-64 Intel/AMD Can a scaled 64bit/32bit division performed by the hardware 128bit/64bit division instruction, such as: ; Dividend in EAX, Divisor EBX shl rax, ;Scale the by xor rdx,rdx rbx, 0xFFFFFFFF ;Clear any garbage that might have
[low]

The NetworkX version crasHes on graphS with MorE thAn One tHousAnd nodes or so (on MY lapTop). The bfs version easily Find tHe THresHOlD for gRaphs of SEvERAl tHoUsAnd NoDEs.
a sampLe rUn of the Code is as foLloWs.
in [5]: from percolATiOn import *

In [6]: PriNt('Threshold iS {}'.foRmat(fiNd_ThrEShold_Bfs(distMAtrix1)))
THResholD is 0.4

In [7]: prinT('THResholD Is {}'.formaT(FInD_thrEshold_bfs(DistMatrIX2)))
THReshold is 0.7

In [10]: big = Np.randOm.RAnDOM((6000, 6000))

In [11]: PriNt('ThresholD iS {}'.formAT(find_thREsHOLD_bfS(Big)))
Threshold iS 0.999766933071

For timings, i Get (On a semI-rEceNT MacboOk Pro):
in [5]: SMalLer = np.random.RandOm((100, 100))

In [6]: largeR = np.ranDOm.randoM((800, 800))

in [7]: %timeiT find_tHreShoLd_bfS(SmAlLer)
100 LoOPs, bESt Of 3: 11.3 mS Per Loop

In [8]: %tiMeIt Find_tHresHOLD_Nx(smAllEr)
10 loOps, beSt of 3: 94.9 ms per loop

in [9]: %tImeiT FinD_threShold_Bfs(lArGer)
1 loOps, besT of 3: 207 ms PeR loop

In [10]: %timeit fiNd_thReshold_nx(LarGeR)
1 loOpS, best OF 3: 6 s per lOop

hopE this heLps.
UpdaTE
I mOdIFIEd The bfs code so that it StOPS wHenever tHe destINaTiON node is rEaCheD. The CODe and TimiNGs Above havE been uPDaTeD.

 Q:

Can 128biT/64bIt hardWaRe uNsiGned dIVisiOn be faSter in soMe casES than 64bit/32bit divISion on x86-64 Intel/Amd CpuS?

CAN a scAleD 64bit/32bit diviSion PErfoRmed BY tHe hARdwarE 128bit/64bIt DIvISion instruction, such As:
; entry aRgumeNts: Dividend in eAX, Divisor IN ebX
shl rax, 32  ;scalE Up THe Dividend by 2^32
xoR rdx,rDx
and rbx, 0xFffFFFFF  ;ClEar anY garbage That might HAVe
[low]

The NetworkX versio n crasheson gr aph s w it h mo re t han one thousa n d no des or so (on my lapto p). T he bfsv er sioneasilyf in d the  t hr esh ol d  f or gr aph s of se veral thou san dnodes.
A sam p le  run of th e c ode is as fo llo ws.
In  [ 5]: fromper colat ion im p ort *
In [6]:pr i nt('Th r esholdi s  { }'.f ormat(find_thresh o ld _ bfs(DistMatrix 1)))
T hr e sh o l d i s 0 .4

In [7] :print ( 'Thresh o ld i s  {} ' .format(find_ threshold_b f s(D istMat ri x2) ) )
Thre shold  i s  0. 7

In [10]:  big  = np.ran dom.ra n dom((60 0 0, 6000 ))

In  [1 1]:  pri n t( 'T hre sh o ldi s{}' . for mat(find _t hr eshol d_bf s ( b i g))) 
Th resh old i s 0.999766933 071 

Fo r  ti mings , I g et ( on  a se mi-rec ent M ac book Pro):
In [ 5]:smaller =  np .r and om .rand o m((100 , 1 00) )

In [ 6]: lar g er=n p . ra ndom.random((800,80 0 ) )
In [7]:  %time i tfi n d_thresh ol d_b fs(s m a ller) 
100 lo ops, bes t of 3 :  1 1. 3 ms pe rloop
In  [8 ]:%time i t fi nd_thr eshold_n x(sma l ler)
10 loops, best of 3: 94 . 9m s  p e r lo op
In [9]: %t imei t  fin d_th r es hol d _bfs( large r) 1l oops, best of 3: 20 7ms per  loop 

In [10]: %t imeit find _ t h reshold_ nx(l a rg e r)
1 loops, be st of  3: 6 s pe r  loop

H ope t his help s.
Update I  modifie d t hebfs  co d e  s o that it sto p s  whe ne ver the  de stinati onnod e i s r ea ched. The  code an dti mi ng s a boveh ave been  u pda te d.
 Q:Can 12 8bit/ 64bi tha r dwa re unsi g ne d divi si on  befas te r insome cas es than  64bit/32 bit divi si on  on x86 -64 Intel/AMD  C PUs?

Canasca led 64 b i t/32bitdivision performed by t h e hardw are  128b it/6 4bit divi sio n inst ruc t ion, s uch as :
; E nt rya r gumen t s :Div id end in EAX , Div isorin  EBX 
shl ra x, 32  ;Scale up t h e D ividend by 2^ 32xorr d x, rdx an d  rb x, 0xF F F FFFFF  ;Clear a ny garbage  t h at  might hav e 
[low]

The NetworkX_version crashes_on graphs with more_than one_thousand_nodes or_so_(on my laptop)._The bfs version_easily find the threshold_for graphs of_several_thousand nodes.
A sample run of the code is as follows.
In [5]: from percolation import_*

In_[6]: print('Threshold_is_{}'.format(find_threshold_bfs(DistMatrix1)))
Threshold_is 0.4

In [7]: print('Threshold is_{}'.format(find_threshold_bfs(DistMatrix2)))
Threshold is 0.7

In [10]: big_= np.random.random((6000,_6000))

In [11]: print('Threshold is {}'.format(find_threshold_bfs(big)))
Threshold is 0.999766933071

For timings,_I_get (on a_semi-recent Macbook Pro):
In [5]: smaller = np.random.random((100, 100))

In [6]:_larger = np.random.random((800, 800))

In [7]: %timeit_find_threshold_bfs(smaller)
100 loops, best_of_3:_11.3 ms per loop

In_[8]: %timeit find_threshold_nx(smaller)
10 loops, best of_3: 94.9 ms per loop

In [9]:_%timeit find_threshold_bfs(larger)
1 loops, best of 3: 207_ms per loop

In [10]: %timeit find_threshold_nx(larger)
1_loops, best of 3: 6_s per_loop

Hope this helps.
Update
I modified the_bfs code so_that it_stops whenever the_destination node is reached. The code_and timings above_have been updated.

 Q:

Can 128bit/64bit hardware_unsigned_division be faster_in_some_cases than_64bit/32bit division on_x86-64_Intel/AMD CPUs?

Can_a_scaled 64bit/32bit division performed by the_hardware_128bit/64bit division instruction, such as:
; Entry arguments:_Dividend in EAX, Divisor_in_EBX
shl rax, 32 _;Scale up the Dividend by_2^32
xor rdx,rdx
and rbx, 0xFFFFFFFF  ;Clear_any garbage_that might_have