Mercurial > repos > shellac > sam_consensus_v3
view env/share/doc/networkx-2.5/examples/graph/plot_expected_degree_sequence.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
line wrap: on
line source
""" ======================== Expected Degree Sequence ======================== Random graph from given degree sequence. """ import networkx as nx from networkx.generators.degree_seq import expected_degree_graph # make a random graph of 500 nodes with expected degrees of 50 n = 500 # n nodes p = 0.1 w = [p * n for i in range(n)] # w = p*n for all nodes G = expected_degree_graph(w) # configuration model print("Degree histogram") print("degree (#nodes) ****") dh = nx.degree_histogram(G) for i, d in enumerate(dh): print(f"{i:2} ({d:2}) {'*'*d}")