<jupyter_start><jupyter_text>Weight's distribution<jupyter_code>def logBinning(degreeList,nbin):
    kmin=min(degreeList)
    kmax=max(degreeList)
    logBins = np.logspace(np.log10(kmin), np.log10(kmax),num=nbin)
    logBinDensity, binedges = np.histogram(degreeList, bins=logBins,density=True)
    logBins = np.delete(logBins, -1)
    return logBinDensity, logBins
weights=[G[u][v]['weight'] for (u,v) in G.edges()]
y,x=logBinning(np.array(weights),20)
plt.loglog(x,y,'o',markersize=10)
plt.xlabel('w')
plt.ylabel('P(w)')
plt.show()<jupyter_output><empty_output><jupyter_text>Strength distribution<jupyter_code>s=list(dict(G.degree(weight='weight')).values())
y,x=logBinning(np.array(s),10)
plt.loglog(x,y,'o',markersize=10)
plt.xlabel('s')
plt.ylabel('P(s)')
plt.show()<jupyter_output><empty_output><jupyter_text>Strength degree correlation<jupyter_code>k=list(dict(G.degree()).values())
plt.loglog(k,s,'o',alpha=0.3)

logBins=np.logspace(np.log2(np.min(k)),np.log2(np.max(k)),base=2,num=15)
ybin,xbin,binnumber=scipy.stats.binned_statistic(k,s,statistic='mean',bins=logBins)
plt.loglog(xbin[:-1],ybin,'o',markersize=10)

plt.xlabel('k')
plt.ylabel('s')
plt.show()
def powerLaw(x, a, b):
    return b*x**(a)
plt.loglog(k,s,'o',alpha=0.3)

logBins=np.logspace(np.log2(np.min(k)),np.log2(np.max(k)),base=2,num=15)
ybin,xbin,binnumber=scipy.stats.binned_statistic(k,s,statistic='mean',bins=logBins)
plt.loglog(xbin[:-1],ybin,'o',markersize=10)

fitx=[i for (i,j) in zip(k,s) if  i<50]
fity=[j for (i,j) in zip(k,s) if i<50]
popt, pcov = curve_fit(powerLaw, fitx, fity)  
#popt, pcov = curve_fit(powerLaw, k, s)  
print (popt[0])
plt.loglog(sorted(k), powerLaw(sorted(k), *popt), '--',c='k',linewidth=3)

plt.xlabel('k')
plt.ylabel('s')
plt.show()<jupyter_output>1.3063774518377387<jupyter_text>ROBUSTNESS  random failures<jupyter_code>fList=np.linspace(0,1,20)
NtoRem=[int(i*G.number_of_nodes()) for i in fList]
print(NtoRem)
import random
sf=[]
for nn in NtoRem[:-1]:
    thisG=G.copy()
    ll=random.sample(G.nodes(),nn)
    thisG.remove_nodes_from(ll)
    thisSf=len(max(sorted(nx.connected_components(thisG), key = len, reverse=True)))
    sf.append(thisSf/float(G.number_of_nodes()))<jupyter_output><empty_output><jupyter_text>attacks<jupyter_code>hh=collections.Counter(dict(G.degree())).most_common()
orderedNodes=[u for (u,v) in hh]
print(orderedNodes[:10])
fList1=np.linspace(0,1,20)
NtoRem=[int(i*G.number_of_nodes()) for i in fList1]
sfAtt=[]
for nn in NtoRem[:-1]:
    thisG=G.copy()
    ll=orderedNodes[:nn]
    thisG.remove_nodes_from(ll)
    thisSf=len(max(sorted(nx.connected_components(thisG), key = len, reverse=True)))
    sfAtt.append(thisSf/float(G.number_of_nodes()))
plt.plot(fList1[:-1],sfAtt,'o-',markerSize=10,label='attack')
plt.plot(fList[:-1],sf,'s-',markerSize=10,label='random failure')
plt.xlabel('f')
plt.ylabel('Sf/N')
plt.legend()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20474879559532003, 'fraction_numerical': 0.026496902959394355, 'mean_word_length': 8.257961783439491, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '101965', 'license': 'MIT', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1303, 'n_words': 141, 'path': 'CC4/exClasse/Seance4_ExerciseClasse3.ipynb', 'repo_name': 'ARKEnsae/DM_Analyse_Reseaux', 'size': '2906'}