-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Long node names break nx_pydot.pydot_layout (and possibly others) #7648
Comments
There's a problem with the nx_pydot.pydot_layout function in NetworkX when you try to use it with really long node names. It can cause errors because it doesn't handle these long names correctly. To fix this, we need to update the code to be smarter about how it deals with empty nodes and raise a clear error message if it can't find the nodes you're looking for. This will stop the errors from happening when you have long node labels. We might need to do some more testing to make sure this fix works with other parts of the code that have to do with layout |
…bly others) networkx#7648 There was a problem with the nx_pydot.pydot_layout function in NetworkX when you had really long node names. It would mess up the layout and cause errors. We fixed this by making the code smarter. Now it checks if the node exists before trying to find its position, and it gives you a clear error message if it can't find it or if there's a problem with the position information. This makes the layout function more reliable, so it won't crash anymore even if you have long or weird node names.
Is there any movement on this? Would be nice to find a fix for it soonish :) |
Is this a problem with pydot or with network or with graphviz? |
Really long node names get split into multiple lines when creating the dot representation via
create_dot()
:This causes the
pydot_layout
function call to be unable to find node names.Current Behavior
nx_pydot.pydot_layout
raisesIndexError
:node
is a list but it is empty:node == []
. It's empty because thenode = Q.get_node(pydot.quote_id_if_necessary(str_n))
line fails to find a node namedstr_n
.Expected Behavior
nx_pydot.pydot_layout
should work even when node names are very long.Steps to Reproduce
Edit this test case and run the test:
You'll see that an IndexError is raised.
Add some error handling to see the exact ValueError I displayed above:
Environment
Python version: 3.11.9
NetworkX version:
main
@ 0aaa392 (2024-09-20 13:47:12 -0700)Pydot version: 3.0.1
Additional context
I haven't investigated where in
pydot
the newlines are being added, or if that's a "feature" ofgraphviz
itself.The text was updated successfully, but these errors were encountered: