Note
Click here to download the full example code
Erdos Renyi¶
Create an G{n,m} random graph with n nodes and m edges and report some properties.
This graph is sometimes called the Erdős-Rényi graph but is different from G{n,p} or binomial_graph which is also sometimes called the Erdős-Rényi graph.

Out:
node degree clustering
0 5 0.4
1 3 1.0
2 3 0.3333333333333333
3 3 1.0
4 6 0.5333333333333333
5 7 0.42857142857142855
6 2 0
7 5 0.7
8 2 0
9 4 0.16666666666666666
the adjacency list
0 4 7 5 8 2
1 4 5 7
2 6 5
3 4 5 7
4 7 5 9
5 7 9
6 9
7
8 9
9
import matplotlib.pyplot as plt
from networkx import nx
n = 10 # 10 nodes
m = 20 # 20 edges
G = nx.gnm_random_graph(n, m)
# some properties
print("node degree clustering")
for v in nx.nodes(G):
print(f"{v} {nx.degree(G, v)} {nx.clustering(G, v)}")
print()
print("the adjacency list")
for line in nx.generate_adjlist(G):
print(line)
nx.draw(G)
plt.show()
Total running time of the script: ( 0 minutes 0.074 seconds)