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:

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)
```
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():

pip install -e .
parse_log_pytest
requirements.txt
nose pytest
apt-get update apt-get install -y libgdal-dev graphviz
3.6
requirements/default.txt requirements/test.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
charset-normalizer==2.0.12
codecov==2.1.13
coverage==6.2
decorator==5.1.1
idna==3.10
importlib-metadata==4.8.3
iniconfig==1.1.1
-e git+https://github.com/networkx/networkx.git@3d7ea0d690e59c2d5d223528ea9e21b21fb7f8a4#egg=networkx
nose==1.3.7
nose-ignore-docstring==0.2
packaging==21.3
pluggy==1.0.0
py==1.11.0
pyparsing==3.1.4
pytest==7.0.1
requests==2.27.1
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
zipp==3.6.0

name: networkx
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - charset-normalizer==2.0.12
      - codecov==2.1.13
      - coverage==6.2
      - decorator==5.1.1
      - idna==3.10
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - nose==1.3.7
      - nose-ignore-docstring==0.2
      - packaging==21.3
      - pluggy==1.0.0
      - py==1.11.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - requests==2.27.1
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - zipp==3.6.0
prefix: /opt/conda/envs/networkx

networkx/generators/tests/test_degree_seq.py::test_expected_degree_graph_skew
networkx/generators/tests/test_degree_seq.py::TestConfigurationModel::test_empty_degree_sequence networkx/generators/tests/test_degree_seq.py::TestConfigurationModel::test_degree_zero networkx/generators/tests/test_degree_seq.py::TestConfigurationModel::test_degree_sequence networkx/generators/tests/test_degree_seq.py::TestConfigurationModel::test_random_seed networkx/generators/tests/test_degree_seq.py::TestConfigurationModel::test_directed_disallowed networkx/generators/tests/test_degree_seq.py::TestConfigurationModel::test_odd_degree_sum networkx/generators/tests/test_degree_seq.py::test_directed_configuation_raise_unequal networkx/generators/tests/test_degree_seq.py::test_directed_configuation_mode networkx/generators/tests/test_degree_seq.py::test_expected_degree_graph_empty networkx/generators/tests/test_degree_seq.py::test_expected_degree_graph networkx/generators/tests/test_degree_seq.py::test_expected_degree_graph_selfloops networkx/generators/tests/test_degree_seq.py::test_havel_hakimi_construction networkx/generators/tests/test_degree_seq.py::test_directed_havel_hakimi networkx/generators/tests/test_degree_seq.py::test_degree_sequence_tree networkx/generators/tests/test_degree_seq.py::test_random_degree_sequence_graph networkx/generators/tests/test_degree_seq.py::test_random_degree_sequence_graph_raise networkx/generators/tests/test_degree_seq.py::test_random_degree_sequence_large
networkx/generators/degree_seq.py
networkx/generators/degree_seq.py