summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaoyang Li <ntlihy@gmail.com>2023-04-17 18:05:40 +0800
committerGitHub <noreply@github.com>2023-04-17 15:35:40 +0530
commit636dd01445424e185a3275ee414da32165284606 (patch)
treef669eaeafc2905547aab37aa71881a77e32d7888
parent5aad3ddbf977bfbb1a11fde01af351c57dcecdc5 (diff)
downloadnetworkx-636dd01445424e185a3275ee414da32165284606.tar.gz
Preserve node order in bipartite_layout (#6644)
* Keep the original order of the nodes in bipartite_layout * Keep the original order of the nodes in bipartite_layout
-rw-r--r--networkx/drawing/layout.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/networkx/drawing/layout.py b/networkx/drawing/layout.py
index 6200b3e3..3e7e61ae 100644
--- a/networkx/drawing/layout.py
+++ b/networkx/drawing/layout.py
@@ -323,9 +323,9 @@ def bipartite_layout(
width = aspect_ratio * height
offset = (width / 2, height / 2)
- top = set(nodes)
- bottom = set(G) - top
- nodes = list(top) + list(bottom)
+ top = dict.fromkeys(nodes)
+ bottom = [v for v in G if v not in top]
+ nodes = list(top) + bottom
left_xs = np.repeat(0, len(top))
right_xs = np.repeat(width, len(bottom))