#

Note

This documents the development version of NetworkX. Documentation for the current release can be found here.

#

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.

../../_images/sphx_glr_plot_erdos_renyi_001.png

Out:

node degree clustering
0 5 0.4
1 2 1.0
2 5 0.4
3 4 0.3333333333333333
4 4 0.3333333333333333
5 5 0.5
6 4 0.6666666666666666
7 6 0.3333333333333333
8 1 0
9 4 0.5

the adjacency list
0 7 4 1 9 5
1 7
2 9 3 7 6 4
3 8 4 7
4 5
5 7 9 6
6 9 7
7
8
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.052 seconds)

Gallery generated by Sphinx-Gallery