diff options
author | Navya Agarwal <82928853+navyagarwal@users.noreply.github.com> | 2023-04-07 06:37:04 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-06 18:07:04 -0700 |
commit | d4e2331db1121c96b5fd09793b28c2e6a9cd03c2 (patch) | |
tree | f6b19e83335bacfa90822d153300abb35f147428 /networkx/drawing/nx_agraph.py | |
parent | 32f8a6c3c14dc9f81eaf7076e71ef58417c42d78 (diff) | |
download | networkx-d4e2331db1121c96b5fd09793b28c2e6a9cd03c2.tar.gz |
Fix handling of pos node attribute in to_agraph (#6474)
Make sure the `"pos"` node attribute is properly formatted for pygraphviz,
if present.
Diffstat (limited to 'networkx/drawing/nx_agraph.py')
-rw-r--r-- | networkx/drawing/nx_agraph.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/networkx/drawing/nx_agraph.py b/networkx/drawing/nx_agraph.py index 2ffa21fd..9a29fab5 100644 --- a/networkx/drawing/nx_agraph.py +++ b/networkx/drawing/nx_agraph.py @@ -137,6 +137,13 @@ def to_agraph(N): ) from err directed = N.is_directed() strict = nx.number_of_selfloops(N) == 0 and not N.is_multigraph() + + for node in N: + if "pos" in N.nodes[node]: + N.nodes[node]["pos"] = "{},{}!".format( + N.nodes[node]["pos"][0], N.nodes[node]["pos"][1] + ) + A = pygraphviz.AGraph(name=N.name, strict=strict, directed=directed) # default graph attributes |