summaryrefslogtreecommitdiff
path: root/examples/graph/expected_degree_sequence.py
diff options
context:
space:
mode:
authorJarrod Millman <jarrod.millman@gmail.com>2017-07-17 11:24:00 -0700
committerDan Schult <dschult@colgate.edu>2017-07-17 14:24:00 -0400
commit471294a157b6cec8d53c36f9e6ceb5ff44c692e1 (patch)
treed036c97af82b9be0b13261c72e61a49c3413100c /examples/graph/expected_degree_sequence.py
parent7a138a1bab6e9eefa92883dfa11fcb45dc8347ca (diff)
downloadnetworkx-471294a157b6cec8d53c36f9e6ceb5ff44c692e1.tar.gz
Fix sphinx (#2517)
* Ensure valid rst file * Edit text * Update README and package docstring * Add myself as a contributor * Update gitwash * Fix warnings/errors except citations/footnotes * Remove old note about 3.0 incompatibility * Remove stale ref to gh-pages * Create top-level tools directory (standard practice) * Use sphinx-gallery extension for examples * Sphinx-gallery generates images for `plot_` examples * Comply with pep8 * Don't save figures
Diffstat (limited to 'examples/graph/expected_degree_sequence.py')
-rw-r--r--examples/graph/expected_degree_sequence.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/examples/graph/expected_degree_sequence.py b/examples/graph/expected_degree_sequence.py
index 0a00851c..c48cac00 100644
--- a/examples/graph/expected_degree_sequence.py
+++ b/examples/graph/expected_degree_sequence.py
@@ -1,5 +1,9 @@
#!/usr/bin/env python
"""
+========================
+Expected Degree Sequence
+========================
+
Random graph from given degree sequence.
"""
# Author: Aric Hagberg (hagberg@lanl.gov)
@@ -15,15 +19,14 @@ from networkx import *
from networkx.generators.degree_seq import *
# 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
+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=degree_histogram(G)
-low=min(degree(G))
-for i in range(low,len(dh)):
- bar=''.join(dh[i]*['*'])
- print("%2s (%2s) %s"%(i,dh[i],bar))
-
+dh = degree_histogram(G)
+low = min(degree(G))
+for i in range(low, len(dh)):
+ bar = ''.join(dh[i] * ['*'])
+ print("%2s (%2s) %s" % (i, dh[i], bar))