English: Erdős–Rényi model random graphs with different values of P. The plot has been obtained by the following Python code:
import networkx as nx
import matplotlib.pyplot as plt
from scipy.stats import bernoulli
colors = ["blue", "red", "green", "yellow"]
probs = [0.1, 0.3, 0.5, 0.8]
N=20
plt.figure()
for n in range(len(colors)):
p=probs[n]
G = nx.Graph()
G.add_nodes_from(range(N))
for node1 in G.nodes():
for node2 in G.nodes():
if bernoulli.rvs(p=p) and node1>node2:
G.add_edge(node1, node2)
plt.subplot(2,2,n+1)
nx.draw(G, node_color=colors[n], edge_color='gray', label="P=" + str(probs[n]), node_size=12)
plt.legend(fontsize = 'small', labelspacing =-1)
plt.show()
plt.savefig("fig.eps")
Català: Grafs aleatoris obtinguts a partir del model d'Erdős-Rényi amb diferents valors del paràmetre P. La gràfica s'ha obtingut a partir del codi de Python:
import networkx as nx
import matplotlib.pyplot as plt
from scipy.stats import bernoulli
colors = ["blue", "red", "green", "yellow"]
probs = [0.1, 0.3, 0.5, 0.8]
N=20
plt.figure()
for n in range(len(colors)):
p=probs[n]
G = nx.Graph()
G.add_nodes_from(range(N))
for node1 in G.nodes():
for node2 in G.nodes():
if bernoulli.rvs(p=p) and node1>node2:
G.add_edge(node1, node2)
plt.subplot(2,2,n+1)
nx.draw(G, node_color=colors[n], edge_color='gray', label="P=" + str(probs[n]), node_size=12)
plt.legend(fontsize = 'small', labelspacing =-1)
plt.show()
plt.savefig("fig.eps")