Repository: networkx/networkx

Issue:
node-mapping bug expected_degree_graph
Hi I used the NX1 expected_degree_graph generator. It has the same interface as the NX2.

https://networkx.github.io/documentation/stable/reference/generated/networkx.generators.degree_seq.expected_degree_graph.html#networkx.generators.degree_seq.expected_degree_graph

But NX2 will not generate the graph correctly. The total number of edge is always 1. No further error message provided. 
Same script works well for NX1. (I downgrade to older version.

```python
D = 10
N = 1000
degree_l = [D for i in range(N)]
G = nx.expected_degree_graph(degree_l, seed=datetime.now(), selfloops=False)
```

Discussion:

Patch:
diff --git a/networkx/generators/degree_seq.py b/networkx/generators/degree_seq.py
index 6d57bcf05..c42faebc7 100644
--- a/networkx/generators/degree_seq.py
+++ b/networkx/generators/degree_seq.py
@@ -426,7 +426,7 @@ def expected_degree_graph(w, seed=None, selfloops=True):
     # weights dictates the order of the (integer) node labels, so we
     # need to remember the permutation applied in the sorting.
     order = sorted(enumerate(w), key=itemgetter(1), reverse=True)
-    mapping = {c: v for c, (u, v) in enumerate(order)}
+    mapping = {c: u for c, (u, v) in enumerate(order)}
     seq = [v for u, v in order]
     last = n
     if not selfloops:


Test patch:
diff --git a/networkx/generators/tests/test_degree_seq.py b/networkx/generators/tests/test_degree_seq.py
index c1aca1791..bde2c7954 100644
--- a/networkx/generators/tests/test_degree_seq.py
+++ b/networkx/generators/tests/test_degree_seq.py
@@ -92,6 +92,8 @@ def test_expected_degree_graph():
     # test that fixed seed delivers the same graph
     deg_seq = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
     G1 = nx.expected_degree_graph(deg_seq, seed=1000)
+    assert_equal(len(G1), 12)
+
     G2 = nx.expected_degree_graph(deg_seq, seed=1000)
     assert_true(nx.is_isomorphic(G1, G2))
 
@@ -105,6 +107,7 @@ def test_expected_degree_graph_selfloops():
     G1 = nx.expected_degree_graph(deg_seq, seed=1000, selfloops=False)
     G2 = nx.expected_degree_graph(deg_seq, seed=1000, selfloops=False)
     assert_true(nx.is_isomorphic(G1, G2))
+    assert_equal(len(G1), 12)
 
 
 def test_expected_degree_graph_skew():
@@ -112,6 +115,7 @@ def test_expected_degree_graph_skew():
     G1 = nx.expected_degree_graph(deg_seq, seed=1000)
     G2 = nx.expected_degree_graph(deg_seq, seed=1000)
     assert_true(nx.is_isomorphic(G1, G2))
+    assert_equal(len(G1), 5)
 
 
 def test_havel_hakimi_construction():