python - How to create scale-free networks with different assortativity in NetworkX? -


given assortativity preference of hubs of network connect other hubs instead of peripheral nodes, want produce 2 scale-free networks using barabasi-albert algorithm different assortativity.

one visual example of given here.

how can "force" networkx create few scale-free networks assortativity coefficients different each other, ones in visual example?

this how create (undirected) barabasi-albert network:

import networkx nx pylab import * import matplotlib.pyplot plt %pylab inline  n=100 #number of nodes ncols=10 #number of columns in 10x10 grid of positions  m=2  #number of initial links seed=[100]  j in seed:      g=nx.barabasi_albert_graph(n, m, j)     pos = {i : (i // ncols, (n-i-1) % ncols) in g.nodes()}     d=g.degree().values()     avg_d=round(sum(d)/100,3)     avg_degree.append(avg_d)     edges.append(len(g.edges()))     nx.draw(g, pos, with_labels=true, nodesize=100, node_color='darkorange',font_size=10)       plt.title('scale-free network (ba)')     plt.show()  #assortativity coefficient (pearson's rho) r=nx.degree_pearson_correlation_coefficient(g) 

this network has assortativity coefficient of -0.2, means hubs have slight preference attach peripheral nodes.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -