diff options
Diffstat (limited to 'networkx/drawing/layout.py')
-rw-r--r-- | networkx/drawing/layout.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/networkx/drawing/layout.py b/networkx/drawing/layout.py index b7637ece..558baff5 100644 --- a/networkx/drawing/layout.py +++ b/networkx/drawing/layout.py @@ -390,6 +390,7 @@ def spring_layout( fixed : list or None optional (default=None) Nodes to keep fixed at initial position. + Nodes not in ``G.nodes`` are ignored. ValueError raised if `fixed` specified and `pos` not. iterations : int optional (default=50) @@ -447,7 +448,7 @@ def spring_layout( if node not in pos: raise ValueError("nodes are fixed without positions given") nfixed = {node: i for i, node in enumerate(G)} - fixed = np.asarray([nfixed[node] for node in fixed]) + fixed = np.asarray([nfixed[node] for node in fixed if node in nfixed]) if pos is not None: # Determine size of existing domain to adjust initial positions |